Monday, February 20, 2012

Record Selection Formula. Impossible?

I have a problem selecting records in my crystal report. There are two string parameters, dateFrom and dateTo. The record selection formula is:

{payroll_history.dateModified} in CDate({?dateFrom}) to CDate({?dateTo})

When typing in the string parameters in crystal, the report works fine, suggesting the fault is in the parsing from vb to crystal. See code below:

Report.Parameters.getItemByName("dateFrom").setCurrentValue(strDateFrom)
Report.Parameters.getItemByName("dateFrom").setCurrentValue(strDateFrom)

HOWEVER, I can display these parameters on the screen perfectly fine when executing the report from VB. Surely this means the selection formula is incorrect?? But it works from within crystal! Argh!

Any help anyone can give me will be so much appreciated.My first thought is that you have a DateTime field, but are trying to use a string parameter. Is payroll_history.dateModified a DateTime field in the database? If so, you need to pass it a DateTime. Also, if it is DateTime and not just Date, you will need to add the hour which, if you don't use a time, will have to be 00:00:00, so the parameter passed would have to be something like 08/12/2006 00:00:00 or else it won't work.

No comments:

Post a Comment