Originally Posted by
FunkyDexter
What line of code does it crash on and what error do you get?
I have a separate form with a Crystal Report control that I pass report definations to named "ReportView". I was able to get the report to view with the correct date ranges using the code below:
'Set selection formula to current record
Set MyReport = Appl.OpenReport("" & strReportPath & "" & strReportName)
MyReport.RecordSelectionFormula = "{DSFHead.DSDate} >= " & "Date (" & Format(FrmPrintDSLog.txtStartDate, "YYYY,mm,dd") & ")" & " AND {DSFHead.DSDate} <= " & "Date (" & Format(FrmPrintDSLog.txtEndDate, "YYYY,mm,dd") & ")"
ReportView.Show vbModal
The problem I am having now is passing the VB form input field (i.e. txtStartDate and txtEndDate) to parameter fields in the Crystal Reports report. These are used to display the date range in the report header.
I have tried both:
dtStartDate = Format(CVDate(txtStartDate.Text), "\D\a\t\e\(yyyy\,mm\,dd\)")
dtEndDate = Format(CVDate(txtEndDate.Text), "\D\a\t\e\(yyyy\,mm\,dd\)")
and
dtStartDate = Format(FrmPrintDSLog.txtStartDate, "YYYY,mm,dd")
dtEndDate = Format(FrmPrintDSLog.txtEndDate, "YYYY,mm,dd")
When I run the following lines of code, I get a "Method 'ParameterFields' of object 'IReport' failed" message.
'Set date paramenter values to print in report
MyReport.ParameterFields(0) = "StartDate; " & dtStartDate & " ; True"
MyReport.ParameterFields(1) = "EndDate; " & dtEndDate & " ; True"
I was hoping I could get some help on how to pass an VB input text box value to a Crystal Report parameter field. Thanks!!!!!