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

VB Crystal reports selection formula

Status
Not open for further replies.

SN082

Programmer
Feb 24, 2002
6
BE
Hello , I have a problem selectioning records with the selectionformula, I allways get an error message "ERROR IN FORMULA" when I try to select records on a valid date variable.
My standard date format is dd-mm-yy and i suppose that the problem lies with Crystal reports, who only mention yyyy-mm-dd in their help section. Can anybody help me with this issue?
btw, I use Crystal reports 4.5, delivered with vb5...
thanks,
stijn

sv
 
A date is passed as: date(yy,mm,dd)
date(2002, 02, 11)

If this doesn't work the post the line of code that you are using and I will help you out further.
 
Hello, many thanks for your help, it's appreciated, anyhow, I'm still facing the problem, I'll give you some additional info:
reports.datee is a date-field in my table
vardate is a variable-date who contains ex 08/03/02
I tried the "#" like in a sql, but this still doesn't work.... I would be glad if you could help...


crpReports.ReportFileName = (apppath & "\" & "RD.rpt")
crpReports.SelectionFormula = "{reports.datee} = '" & "#" & vardate & "#" & "'" & "and {reports.airline} = '" & strAirlineCode & "'"""
crpReports.Action = 1


 
Try this:
Dim strDate As String

strDate = CStr(Year(vardate) & "," & Month(vardate) & "," & Day(vardate))

crpReports.SelectionFormula = = "{reports.date}=Date(" & strDate & ")"

Please note: I am assuming with the reference "reports.date", that "reports" is the table name and "date" is the field name, and also vardate is a date variable.

If so, then this will work
 

This may be easier:

strDate = Format$(vardate,"yyyy,m,d")

crpReports.SelectionFormula = = "{reports.date}=Date(" & strDate & ")"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top