Using an option group to filter a report

ErinL

Registered User.
Local time
Today, 13:03
Joined
May 20, 2011
Messages
118
Hello -

I have an option group called ReportType set up on a form with two options that will determine the date range selected for a report.

In the OnClick event of the button to open the report I have the following:

If Me.ReportType.Value = 1 Then
DoCmd.OpenReport "rptCorrectiveAction", acViewPreview, , "OccurrenceDate > " & DateAdd("m", -12, Date)
Else
DoCmd.OpenReport "rptCorrectiveAction", acViewPreview
End If

I do not receive any errors that my code is wrong but the report does not filter the dates.

Can someone please tell me what I am doing wrong?
 
The dates need octothorpes (#)

DoCmd.OpenReport "rptCorrectiveAction", acViewPreview, , "OccurrenceDate > #" & DateAdd("m", -12, Date) & "#"
 
Try;
Code:
If Me.ReportType.Value = 1 Then
DoCmd.OpenReport "rptCorrectiveAction", acViewPreview, , "OccurrenceDate > [COLOR="Red"]#[/COLOR]" & DateAdd("m", -12, Date) [COLOR="Red"]& "#"[/COLOR]
Else
DoCmd.OpenReport "rptCorrectiveAction", acViewPreview
End If
 
Oh no! I was afraid it was going to be that easy! I really should have caught that. :o
Guess it's turning into one of those days. Thank you so much for your replies.
 

Users who are viewing this thread

Back
Top Bottom