Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

including VB Variable into Crystal Report

Status
Not open for further replies.

codo

IS-IT--Management
Oct 31, 2001
187
ID
this is the code i'm using to display Crystal report 9.0 from my VB 6 code :

Private Sub Form_Load()
Dim crystal As CRAXDRT.Application
Dim report As CRAXDRT.report
Dim vFilter as string

vFilter = "Finance"

CRViewer.DisplayBorder = False 'MAKES REPORT FILL ENTIRE FORM
CRViewer.DisplayTabs = False 'THIS REPORT DOES NOT DRILL DOWN, NOT NEEDED
CRViewer.EnableDrillDown = False 'REPORT DOES NOT SUPPORT DRILL-DOWN
CRViewer.EnableRefreshButton = False 'ADO RECORDSET WILL NOT CHANGE, NOT NEEDED
CRViewer.EnableCloseButton = True

Set crystal = New CRAXDRT.Application 'MANAGES REPORTS
Set report = crystal.OpenReport(rep_name) 'OPEN OUR REPORT

report.DiscardSavedData 'CLEARS REPORT SO WE WORK FROM RECORDSET

'report.Database.SetDataSource rs 'LINK REPORT TO RECORDSET

CRViewer.ReportSource = report 'LINK VIEWER TO REPORT
CRViewer.Height = Me.Height
CRViewer.Width = Me.Width
CRViewer.ViewReport 'SHOW REPORT

End Sub


The problem is i don't know how to include the vFilter variable to the report so the report will only display all the records field that match with vFilter value.
 
set the Crystal report object property selectionformula equal to the SQL that you want executed I.e.

sql_string = "column_name_1 = condition_1 and column_name_2 = condition_2"

CRViewer.selectionformula = sql_string

HTH.
 
I couldn't find selectionformula property on CRViewer 9 object, so what property should i put the sql_string ?
What if i want to include the vFilter variable into the report to display it ?
 
Try .RecordSelectionFormula or .ReplaceSelectionFormula (I think .ReplaceSelectionFormula is the old syntax for Crystal 8.x, forgive me if it is wrong).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top