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

Passing a Date Parameter into a report (VB) 2

Status
Not open for further replies.

klameer

Technical User
Jun 21, 2002
26
LK
Hi! This problem is driving me crazy,
I'm trying to pass a date parameter into a report through VB. My Code is as follows

With CrystalReport1

.ReportTitle = frmMain.strRptName
.ReportFileName = App.Path & "\test.rpt"
.ParameterFields(0) = "fromDate;" & txtDateFrom.Text & ";true"
.ParameterFields(1) = "toDate;" & txtDateTo.Text & ";true"
.Action = 1
End With

I have creatd fromDate and toDate Parameters within the report.
Everytime I try to run the application, I get an "Invalid Parameter field value" error. I have tried all possible sceanarios that I know of, even formatting the date (format(cdate(txtDateTo.txt), "dd-mm-yyyy")) but I get the same error.
Can someone please help, I will be eternally grateful.

Regards,

Karim
 
Try passing the date parameter as

Date(YYYY,MM,DD) or just YYYYMMDD

This is how Crystal likes the format.

Reebo
UK

Please Note - Due to current economic forcast and budget constraints, the light at the end of the tunnel has been switched off. Thank you for your cooperation.
 
Hi reebo,
What is I tried the format .ParameterFields(1) = "fromDate;20010101;true" and .ParameterFields(1) = "fromDate;2001,01,01;true" and both dont work.
I dont unserstand Date(YYYY,MM,DD) on visual basic, Date is not a function, I even tried cDate(yyyy,mm,dd) but that dosent work either.

Regards,

Karim
 
Did you try passing Date(YYYY,MM,DD)?

I know Date(YYYY,MM,DD) is not a function within Visual basic, but it is within crystal.

I'm not saying this will definately work as my experience is limited. but try :
"fromDate;Date(2001,01,01);true"

If this doesn't work, try posting the same question in
Crystal Decisions: Crystal Reports 3 Integrate forum or the Visual Basic forums.

Reebo
UK

Please Note - Due to current economic forcast and budget constraints, the light at the end of the tunnel has been switched off. Thank you for your cooperation.
 
Looks like this might help you?

thread768-699772

Reebo
UK

Please Note - Due to current economic forcast and budget constraints, the light at the end of the tunnel has been switched off. Thank you for your cooperation.
 
The .ocx control is goofy about this date thing. Try this:

.ParameterFields(0) = "fromDate;Date(" & Year(CDate(txtDateFrom.Text)) & "," & _
Month(CDate(txtDateFrom.Text)) & "," & Day(CDate(txtDateFrom.Text)) & ");true"

-dave
 
Thanks guys you've been very helpful

Regards,

Karim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top