Sunday, February 19, 2012

Create Dynamic Report

Mr. Babu,

How can I manipulate the query from VB depending on the input entered by the user. In this case I can make one report only and modify the query and pass it to the report.
Otherwise for each user input I will have call a different report.
If possible do send me an example.

Thanks,

SatishHave you try to pass parameters to your report?|||I have tried parameters and it works, but I would like to chang the sql
i.e. select * from .... where empno= variable

regards,
Satish|||This may be more trouble than it's worth...

You could change your report so that VB does all the database queries and passes a recordset to your report.

Example 1:

Dim CrApp1 As New CRPEAuto.Application
Dim CrRep As CRPEAuto.Report
Dim CrDB As CRPEAuto.Database
Dim CrTables As CRPEAuto.DatabaseTables
Dim CrTable As CRPEAuto.DatabaseTable

'open report
Set CrRep = CrApp1.OpenReport("C:\Report.rpt")

'set the database object to the reports database
Set CrDB = CrRep.Database

'Set the databasetables object
Set CrTables = CrDB.Tables

'set the databasetable object to the first table in the report
Set CrTable = CrTables(1)

'sets ADO recordset as the data for the first table
CrTable.SetPrivateData 3, rsData

'preview the report with the ADO recordset as the data
CrRep.Preview

Example 2 (uses RDC, which I like better):

Dim Report As New CrystalReport1

Report.Database.SetDataSource rsData, 3, 1

CRViewer1.ReportSource = Report
CRViewer1.ViewReport

In Example 2, CrystalReport1 is the dsr file created by clicking 'Project', 'Add Crystal Report 8.5' in the VB IDE. CRViewer1 is the Crystal Report Viewer component.

Both of these examples were created using CR 8.5 and VB 6.|||This is in reference to your reply.

In Example 2, CrystalReport1 is the dsr file created by clicking 'Project', 'Add Crystal Report 8.5' in the VB IDE.

When I click Project, I cannot see "Add Crystal Report 8.5".
How do I get it.

Regards,
Satish|||I am not getting CRPEAuto method. What reference has to be made.

what does crpeauto stand for?|||My References for the 'CRPEAuto' Method says 'Crystal Report Engine 8 Object Library'

As for the 'Add Crystal Report 8.5', do you have Crystal Reports Developer Edition installed on your development machine? If so, what version? I think RDC was made avaiable in either version 8 or 8.5 and higher.

You can try to do a search on Crystal's website:
http://support.businessobjects.com/search/advsearch.asp|||how do I get the reference to "'Crystal Report Engine 8 Object Library'" in my computer.|||I'm using version 8.5 Developer Edition. When I installed it, it placed all the necessary dlls on my comuter for me.

Click 'Project', 'References', and check 'Crystal Report Engine 8 Object Library'

No comments:

Post a Comment