Link to home
Start Free TrialLog in
Avatar of dimensionav
dimensionavFlag for Mexico

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
Avatar of Mike McCracken
Mike McCracken

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
Avatar of dimensionav

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of dimensionav
dimensionav
Flag of Mexico image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.