help with code

R

Richard

Hi

I am trying to change the recordsource of a report in the onopen event.

A part of the code is below, I am trying to process only the records from
today onwards, It works in the query but it shows all records when the
report is opened.

Thanks in advance for your help

Richard

Me.Report.RecordSource = "SELECT ......... " & _
"WHERE (((Enrolments.WORKSHOPDATE)>= " & Date & ") AND
((Enrolments.Cancelled)=False)) " & _
"ORDER BY Enrolments.WORKSHOPDATE DESC;"
 
A

Allen Browne

When the date is concatenated into the string, it needs to be delimited with
#.

If you are working in a non-US country, you also need to specify the
American date format.

Try:
Me.Report.RecordSource = "SELECT ......... " & _
"WHERE (((Enrolments.WORKSHOPDATE)>= " & Format(Date,
"\#mm\/dd\/yyyy\#") & _
") AND ((Enrolments.Cancelled)=False)) " & _
"ORDER BY Enrolments.WORKSHOPDATE DESC;"
 
R

Richard

Thanks Allen




Allen Browne said:
When the date is concatenated into the string, it needs to be delimited with
#.

If you are working in a non-US country, you also need to specify the
American date format.

Try:
Me.Report.RecordSource = "SELECT ......... " & _
"WHERE (((Enrolments.WORKSHOPDATE)>= " & Format(Date,
"\#mm\/dd\/yyyy\#") & _
") AND ((Enrolments.Cancelled)=False)) " & _
"ORDER BY Enrolments.WORKSHOPDATE DESC;"
 
Top