Syntax for wildcard for dates

R

RoadKyng

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
 
O

Ofer Cohen

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top