Syntax for wildcard for dates

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

Guest

I have the following code in a report that will use the date fields if
selected, but inserts wildcards to get any available date. I am getting a
syntax error. The report filter is also shown below:

'CHECK FOR DATE RANGES
If IsNull(Me.DateIN.Value) Then
DateIN = "Like '*'"
Else
DateIN = Me.DateIN
End If

If IsNull(Me.DateOUT.Value) Then
DateOUT = "Like '*'"
Else
DateOUT = Me.DateOUT
End If




'SET THE REPORT FILTER
strFilter = "[CorpName] " & strSELECT & " AND [Status] " &
strSTATUS & " AND [Certificate] " & strCertificate & " AND [TrainingDate] " &
"Between #" & DateIN & "# and #" & DateOUT & "#"

I have verified the report works if the dates are supplied but I get an
error if left blank. I have searched the help files and the user groups to no
avail.
GmH
 
Change the wild card to date that it's not possible to get earlier or later
from

If IsNull(Me.DateIN.Value) Then
DateIN = #1/1/1900#
Else
DateIN = Me.DateIN
End If

If IsNull(Me.DateOUT.Value) Then
DateOUT = #1/1/2500#
Else
DateOUT = Me.DateOUT
End If

You trying to run a query that look like

FieldName Between #Like '*'# and #Like '*'#
so it doesn't recognize it as dates
 
Back
Top