Run time error

S

sofiac

I am receiving Run-time error '3075':
Syntax error (missing operator) in query expression 'Incident Date Between
#04/01/2008# And #04/28/2008#'.
The event procedure is:

Dim strReport As String 'Name of report to open.
Dim strField As String 'Name of your date field.
Dim strWhere As String 'Where condition for OpenReport.
Const conDateFormat = "\#mm\/dd\/yyyy\#"

strReport = "rptICUMidasDataTEST"
strField = "Incident Date"

If IsNull(Me.txtStartDate) Then
If Not IsNull(Me.txtEndDate) Then 'End date, but no start.
strWhere = strField & " <= " & Format(Me.txtEndDate,
conDateFormat)
End If
Else
If IsNull(Me.txtEndDate) Then 'Start date, but no End.
strWhere = strField & " >= " & Format(Me.txtStartDate,
conDateFormat)
Else 'Both start and end dates.
strWhere = strField & " Between " & Format(Me.txtStartDate,
conDateFormat) _
& " And " & Format(Me.txtEndDate, conDateFormat)
End If

Any clues why I'm receiving this message?
 
B

boblarson

Your line continuation character is in the wrong place (or the ampersand,
depending on how you look at it):

Change to this:

Else 'Both start and end dates.
strWhere = strField & " Between " & Format(Me.txtStartDate,
conDateFormat) & _
" And " & Format(Me.txtEndDate, conDateFormat)
End If

--
Bob Larson
Access World Forums Administrator

Tutorials at http://www.btabdevelopment.com

__________________________________
 
S

sofiac

The change didn't seem to work. I'm still getting the same error.

Is there a different way I can create a form to enter a date range for a
report?
 

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