Visual dBASE 7.x and
Crystal Reports 7 via ActiveX
by Michael Kusch (translated by Jason Walker)

ANY VdB 5.x user upgrading to VdB 7.x will miss the Crystal report. The Report designer provided with VdB 7.0 is, gently said, not to everyone’s taste. However, here is the good news: merging Crystal Reports in VdB 7.x with the help of its ActiveX control is a simple affair.

In this article, I will describe how Crystal Reports 7 and Visual dBASE can be merged through the former’s ActiveX component. Crystal Reports 7 can process the new DBF level 7 format, since it is accessed through the BDE. Nevertheless, printing memo fields necessitates a primary key in the table.

When you install Crystal Reports, its ActiveX control (called Crystal report control) is available. To take advantage of it, open a form in the Form designer and drag’n drop that control from the Component palette (under the ActiveX tab) unto your form. If that control is not listed in the Component palette, use the method explained in the dBulletin to make it available.

Once dropped on the form, the following lines are added to the constructor code

| `This.activex1 = new ACTIVEX(this)` `endwith`

The Inspector will not list the Crystal report control’s functions and properties under `form.activex1` but rather under `form.activex1.nativeobject` .

Since printing is usually started through an event, this is where the ActiveX control should be called.

| `Function Pushbutton1_onclick` `Class::Printing_with_Crystal()` `Return` `Function Printing_with_Crystal` `x = form.activex1.nativeObject` `x.ReportFileName="Myreport.rpt"` `x.CopiesToPrinter=1` `x.destination=0` `x.windowcontrols=true` `x.windowShowPrinterSetupBtn=true` `x.windowTitel="Testreport"` `x.windowShowGroupTree=true` `x.WindowSearchBtn=true` `x.action=1` `Return`

The Crystal Report ActiveX control's main functions and properties are:

ReportFileName
Transfers the names of the report to the module.

CopiesToPrinter
The number of copies to send to the printer(they are not displayed in the Viewer however).

Destination
Target of the report, whereby
0 = Window (Preview window)
1 = Printer
2 = File
3 = E-Mail
6 = Exchange folder

WindowControls
Switches the printer control buttons in the Preview window on/off.

WindowShowPrinterSetupBtn
Shows or hides the button for the print output.

WindowTitle
Transfers a window heading.

WindowShowGroupTree
Switches the group tree on/off.

WindowSearchBtn
Switches the search possibility in the Preview window on/off.

Action
Starts the ActiveX module with its defaults.

This overview of the available methods and properties was made with the help of Crystal Reports Developer’s Guide. Its examples are written in VB. This means that some methods do not lead to the desired result. For example, I was unable to use the method `Datafiles(n)` that should modify the paths indicated in the report.

The files needed for deployment are listed in the Runtime help file. The ActiveX control must be installed with `REGSRV32.exe` and `CRYSTL32.ocx` on each computer. That could be done by InstallShield. The methodology needed is described in section 1.3 of Michael Rotteck’s “InstallShield Express for Visual dBASE 7” published in German in the fourth issue of the dBulletin.

Finally, with Crystal, it is also possible to compile your report as an executable. This can be done almost without programming.

About the author:
Michael Kusch uses dBASE since 1993. He develops commercial applications with Visual dBASE.

Michael Kusch
EDP service 81245 Munich
Tel.: 089-89712763
fax: 089-89712290

The dBulletin would like to thank Richard Perryman for submitting the translation to our magazine. We would like to thank also Fabian Cevallos and David L. Stone for proof-reading this article.