Has someone used the Crystal Report Designer Component? 
Author Message
 Has someone used the Crystal Report Designer Component?

Now I'm using the Crystal Report Designer Component. Can someone tell me
how to set the datasource by coding. In the help, I can't find it.
Thanks


Mon, 18 Feb 2002 03:00:00 GMT  
 Has someone used the Crystal Report Designer Component?
I can't believe that you seriously looked in the documentation. There is a
whole lot written on this topic. I will quote some:

"Setting a new data source for the report:

One of the most common tasks with the Report Designer Component is to
specify a different data source at runtime from the one used to design the
report. For example, you may want to provide a report containing a default
set of data, then allow your users to customize the results by making
selections in your application. At runtime, you create a new set of data
based on the user's choices, then use that new data source to replace the
default data in the report.
Field Definition Files allow you to design the report without even
specifying an actual data source. For instance, your data source may be
highly dynamic, or it may even be nonexistent until runtime. You can design
the report based on the Field Definition File, then create your data source
at runtime and hand it off to the report before printing.
The following code creates a new ADO Recordset object, assigns the new
recordset to the report, then assigns the report to the Smart Viewer control
for display on screen.

Private Sub Form_Load()
 Dim Report As New CrystalReport1
 Dim ADOrs As New ADOR.Recordset
 ADOrs.CursorLocation = adClientSide
 ADOrs.Open "SELECT * from Customer WHERE country = 'USA'", _
  "DSN=Xtreme sample data;", adOpenKeyset
 Report.Database.SetDataSource rs ,3,1
 CRViewer1.ReportSource = Report
 CRViewer1.ViewReport
End Sub

Notice that this code is handled in the Load event of a Form. This would
normally be the form that contains the Smart Viewer ActiveX control.
Handling this process during the load event of the Smart Viewer form is the
quickest and easiest means of assigning new data to the report.
In the first line of code, a new Report variable is defined as an instance
of the Report Designer Component that has been added to the Visual Basic
project. Immediately after that, a new ADO Recordset object is defined. The
Recordset object is then assigned a set of data (a recordset) using a SQL
query statement. In this example, the statement is hard-coded into the
application. However, you could easily design an application that
dynamically generates a query statement based on a user's input or
selections.

Next, the SetDataSource method of the Report Designer Component's Database
object is used to specify that the new ADO Recordset should be used to
generate the report. SetDataSource accepts a single argument: the Recordset
object itself. This argument could also be a DAO Recordset or an RDO
Resultset, or any other data access methods. The only restriction on the
data source assigned using SetDataSource is that it contain fields that
match the fields used to originally create the report. For instance, if the
report was created using three string fields named SSN, LastName, and
FirstName, the new data source must also consist of three string fields
named SSN, LastName, and FirstName.
The last two lines of code in this example assign the report object
containing the new data source to the Smart Viewer ActiveX control that
appears in the Form, and displays the report. When the Form is loaded by
your Visual Basic application, the report will be displayed with the new
data from the ADO Recordset.



Fri, 22 Feb 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Using Crystal Report Designer Component need to use mulitiple databases with same tables

2. Using Crystal 8.0 Report Designer Component

3. Crystal Reports 6 Report Designer Component

4. Crystal Reports Report Designer Component

5. Crystal Report Designer Component (Previewing a report.)

6. Crystal Reports "Report Designer Component"

7. Crystal Report Designer Component (Previewing a report.)

8. crystal Report designer component question?

9. No Crystal reports in Component Designer

10. Seagate Crystal Report Designer Component

11. Crystal Reports Designer Component

12. VB 6 / Crystal Report Designer Component (7.0)

 

 
Powered by phpBB® Forum Software