dimensionav
asked on
How to change the sql of a Crystal Report using vb6?
HI
I have a report created in crystal reports with a query that shows all invoices from a database and I have a DLL in which I use the following objetcs to show the report:
Dim report As CRAXDDRT.Report
Dim DB As CRAXDDRT.DatabaseTable
Dim application As CRAXDDRT.Application
If I see the preview there are all the invoices in it so what I want is to change the original query a little bit, just filter it by the Invoice ID using VB 6, and the show it, any ideas?
Regards
I have a report created in crystal reports with a query that shows all invoices from a database and I have a DLL in which I use the following objetcs to show the report:
Dim report As CRAXDDRT.Report
Dim DB As CRAXDDRT.DatabaseTable
Dim application As CRAXDDRT.Application
If I see the preview there are all the invoices in it so what I want is to change the original query a little bit, just filter it by the Invoice ID using VB 6, and the show it, any ideas?
Regards
ASKER
I do Something like this:
ReportPath = "c:\demo\myreport.rpt"
Set oReport = oApplication.OpenReport(Re portPath, 1)
Set DB = oReport.Database.Tables(1)
DB.Location = "c:\demo\mydb.mdb"
ShowReport = True
CRViewer.ReportSource = oReport
CRViewer.DisplayGroupTree = False
CRViewer.Zoom 1
CRViewer.ViewReport
Te previous code shows the report with the query created at design time so I would like to modify that query.
Thanks
ReportPath = "c:\demo\myreport.rpt"
Set oReport = oApplication.OpenReport(Re
Set DB = oReport.Database.Tables(1)
DB.Location = "c:\demo\mydb.mdb"
ShowReport = True
CRViewer.ReportSource = oReport
CRViewer.DisplayGroupTree = False
CRViewer.Zoom 1
CRViewer.ViewReport
Te previous code shows the report with the query created at design time so I would like to modify that query.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I have seen that this object Set DB = oReport.Database.Tables(1) has the hability to change its content by using a recordset, something like this:
Set rst = New Recordset
rst.Open sql, Conn, adOpenForwardOnly, adLockReadOnly
DB.SetDataSource rst
And voila! now I have the records that I want.
Set rst = New Recordset
rst.Open sql, Conn, adOpenForwardOnly, adLockReadOnly
DB.SetDataSource rst
And voila! now I have the records that I want.
How are you calling the report. WIth the code I use for CRAXDRT it is
rpt_Object.RecordSelection
mlmcc