View Single Post
  #3 (permalink)  
Old July 6th, 2007, 07:01 AM
SerranoG SerranoG is offline
Friend of Wrox
Points: 4,007, Level: 26
Points: 4,007, Level: 26 Points: 4,007, Level: 26 Points: 4,007, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Not quite, Rob. Formatting is used only for the purposes of displaying something on a form or report. It is not used as a criteria for a query or as a WHERE condition.

Also, the date range is supposed to be a date, not just a month. Assuming [IncidentMonth] is a full date, then you simply need

DoCmd.OpenReport stDocName, acPreview, , _
    "[IncidentMonth] Between #" & Forms.frmRunReport.Form.FromDate & "# And #" & Forms.frmRunReport.Form.ToDate & "#"

Or if the code is already being called from frmRunReport, then

DoCmd.OpenReport stDocName, acPreview, , _
    "[IncidentMonth] Between #" & Me.FromDate & "# And #" & Me.ToDate & "#"

If IncidentMonth is truly a month and not a full date, then you need to do something like this, keeping in mind that the month is an integer (no # needed).

DoCmd.OpenReport stDocName, acPreview, , _
    "[IncidentMonth] Between " & Month(Me.FromDate) & " And " & Month(Me.ToDate)

Month() is a built-in Access function and should not be used as a field or variable name.
Reply With Quote