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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display VB6 variable In 'Externally referenced' Crystal Report ver8

Status
Not open for further replies.

Pulser

Programmer
Apr 26, 2002
3
0
0
GB
' I connected to a Crystal Report using:
Public Appn As New CRAXDRT.Application
Public cReport As New CRAXDRT.Report
Set Appn = CreateObject("CrystalRunTime.Application")
Set cReport = Appn.OpenReport(C:\Cost By Customer.rpt")

' Used CRViewer to view within VB:
CRViewerCustomer.ReportSource = cReport
cReport.ReadRecords

' & selected only records within gStartDate and gEndDate:
cReport.RecordSelectionFormula = &quot;({qryCustomerCost.Date_Requested} >= #&quot; & gStartDate & &quot;#) and ({qryCustomerCost.Date_Requested} <= #&quot; & gEndDate & &quot;#) & &quot;)&quot;

' Then viewed the report using:
CRViewerCustomer.ViewReport
Set cReport = Nothing
Set Appn = Nothing

Does anyone know how to pass the variables eg gStartDate into Crystal Reports for display there?? Note the 'Insert @UnboundDate' option seems only to be available when the report is embedded using Add Crysatal Reports 8,

Has anyone solved this??

any help appreciated
Connor
 
You can create parameters in the Crystal Report and pass values to them from VB.

These parameters need not be part of the SQL statement to run the report. They might be a custom header to the report, who is runnnig the report from VB, etc.

After you add the parameters in the report, you can use .AddCurrentValue of the .ParameterFields() array to pass the values to Crystal from VB.
 

I added parameter ?Start Date to Crystal as a String

then tried:
cReport.ParameterFields.Item(2).AddCurrentValue (&quot;Text&quot;)

Report displays but 'Text' is not added

Item(2) can be seen in Watches window OK.

Is there some setting in the parameters property I need to set?

Thanks in advance..
 
If this is the only parameter in the report, then the index is 1. Otherwise, it's whatever the index is with the first parameter being 1, etc.

cReport.ParameterFields(1).AddCurrentValue &quot;Text&quot;

And you need to place the parameter somewhere on the report, of course.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top