eliminating dates in a report

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Here is my code for trying to run a report for expired MVR. DateLastMVR is
from my table, and PastDate is from my form. This report should eliminate
anything less than a year old, but I dont get anything when I run the report.
Any suggestions?

Dim stDocName As String
stDocName = "rptExpiredMVR"
DoCmd.OpenReport "rptExpiredMVR", acViewPreview, , "[DateLastMVR] < " &
Me.PastDate
Exit_Command9_Click:
Exit Sub
 
justlearnin said:
Here is my code for trying to run a report for expired MVR. DateLastMVR is
from my table, and PastDate is from my form. This report should eliminate
anything less than a year old, but I dont get anything when I run the report.
Any suggestions?

Dim stDocName As String
stDocName = "rptExpiredMVR"
DoCmd.OpenReport "rptExpiredMVR", acViewPreview, , "[DateLastMVR] < " &
Me.PastDate


You are constructing a string for the WhereCondition
argument. The result of the concatenation will probably end
up looking like [DateLastMVR] < 8/18/05 depending on your
regional settings.

That may look fine to you, but to Access it looks like 8
divided by 18 divided by 5, which a pretty small number and
you have no records like that. To tell Access that you are
providing a date and not some sequence of divisions, you
must enclose the date in # signs. Because of various
regional setting possibilities, the safe way to construct
the WhereCondition is:

,"[DateLastMVR]<" & Format(Me.PastDate,"\#m\/d\/yyyy\#")
 
Back
Top