Filtering date field by month to open report

cath_hopes

Registered User.
Local time
Today, 16:02
Joined
Oct 17, 2007
Messages
52
My form has buttons to open a report for records with [Date of Appointment] either:
2 months ago, 1 month ago, current month, next month or next month +1.
The report it opens is based on a crosstab query that contains the [Date of Appointment] field which is a Date/Time field of format Medium Date. My problem is how to filter the report by these month criteria. I've tried a couple of things:

Firstly, in the query I've created a field Expr2: Format$([Date of Appointment],"mmmm yyyy",0,0) and this returns the month yyyy. I then set the criteria for this field to =Format$("Date","mmmm yyyy",0,0) to get the current month records but no records were returned. Even if this had worked it would have meant having to write 5 queries so not that efficient a solution.

Secondly I tried:
DoCmd.OpenReport strDocName, acViewPreview, , strWhere
where strWhere = ""Format$(Booking.[Date of Appointment], 'mmmm yyyy', 0, 0)=" & Me.txtmonthchosen
This returns run-time error '3075': Syntax error (missing operator) in query expression 'Format$(Booking.[Date of Appointment], 'mmmm yyyy', 0, 0)=February 2008'.

Any suggestions/ help gratefully received!!
 
Try the first one with a criteria of

Format$(Date(),"mmmm yyyy",0,0)
 

Users who are viewing this thread

Back
Top Bottom