How to change the sql of a Crystal Report using vb6?

dimensionav
dimensionav used Ask the Experts™
on
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
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:
I recommend you change the CRAXDDRT to CRAXDRT.  CRAXDDRT can require extra licensing when distributing to clients.  Last time I checked it was $300 per license.  Unless you are providing users the abaility to design reports you don't need it.

How are you calling the report.  WIth the code I use for CRAXDRT it is

rpt_Object.RecordSelectionFormula = "{SomeField} = " & yourtextfield.value

mlmcc

Author

Commented:
I do Something like this:

ReportPath = "c:\demo\myreport.rpt"
Set oReport = oApplication.OpenReport(ReportPath, 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
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.

Author

Commented:
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.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial