As discussed at the beginning of the chapter, the RDC actually consists of four different main
The first step is to assign the design-window report definition to a Visual Basic object variable, as demonstrated in the following sample code:
Public Report As New dsrXtreme
In this code, from the modXtreme module in the sample application,
dsrXtreme
is the
CRViewer1.ReportSource = Report
In this code, CRViewer1 is the default name of the Report Viewer (and it hasn t been changed to another name). The Report object is given to the ReportSource property so that the Report Viewer
What the RDC Library does between defining the Report object and assigning it to the Report Viewer is the meat of RDC integration programming. After you assign the designer to the Report object variable, an entire object model becomes available to you for modifying and customizing the report. By using the RDC s object model, consisting of objects, collections, properties,
When you add the RDC to your report, the CRAXDRT (Crystal
Although an extensive explanation of COM and its general approach to an object model and object hierarchy is better left to Microsoft documentation, navigating the RDC object model will soon become second nature to you. The highest level in the object hierarchy is the Application object ”everything eventually
| Tip |
If you are using the Embeddable Report Designer to give your end user interactive report design capability, you ll want to use the combined design-time/run-time library, CRAXDDRT. Look up this library in the Object Browser to explore its objects, collections, properties, and methods. The Embeddable Report Designer is discussed in more detail later in this chapter. |
One of the main benefits of the RDC is the ability to design a report entirely from within the Visual Basic IDE. When you save this internal report design, the designer specifications are saved in a .DSR file along with the rest of your Visual Basic project. When you compile the project, all of the report design specifications are saved in the compiled modules ”there are no external report files to be accidentally deleted or modified (either
However, sometimes you may want to use the flexibility of the RDC and Report Viewer with an external .RPT file, similar to older Crystal Reports integration methods. This is entirely possible, and quite straightforward. Examine the following code module from a VB form.
Notice the code is very similar to the standard code the RDC automatically adds to your project. Notice a couple of differences, however. Rather than declaring and creating one Report object, consisting of an instance of the ActiveX designer, this code declares and
When you use the built-in RDC ActiveX designer, you needn t worry about the Application object. However, if you choose to use an external report instead of the built-in designer, you ll need to declare and assign a single new instance of the Application object, the highest-level object in the RDC s object hierarchy. Don t forget to fully qualify the Application object by
The Report object is crucial. You ll use it to perform almost all run-time customization to your reports. You need to declare and assign a Report object for each report you want to have
Assign the Report object by using the Application object s OpenReport method. Supply the external report s filename, including the full
| Caution |
If you decide to use the RDC with an external .RPT file and don t use the Add Crystal Reports 10 option from the Project menu, you need to ensure that the RDC Run-Time Library (or combined Design/Run-Time Library) and,
|