CTQE
Registered User.
- Local time
- Today, 13:01
- Joined
- Feb 27, 2008
- Messages
- 48
Hello All,
I have an error message that states:
Run-time error '3075':
Syntax error (missing operator) in query expression '(DATE OF CLASS between #06/01/2007# And #07/01/2008#)'.
Going into the debug, the last line of the code is highlighted
DoCmd.OpenReport strReport, acViewPreview, , strWhere
Here is all of my code:
Private Sub okay_Click()
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 = "rpt_Overdue_Training"
strField = "DATE OF CLASS"
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
End If
' Debug.Print strWhere 'For debugging purposes only.
DoCmd.OpenReport strReport, acViewPreview, , strWhere
End Sub
Please help, Thanks
I have an error message that states:
Run-time error '3075':
Syntax error (missing operator) in query expression '(DATE OF CLASS between #06/01/2007# And #07/01/2008#)'.
Going into the debug, the last line of the code is highlighted
DoCmd.OpenReport strReport, acViewPreview, , strWhere
Here is all of my code:
Private Sub okay_Click()
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 = "rpt_Overdue_Training"
strField = "DATE OF CLASS"
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
End If
' Debug.Print strWhere 'For debugging purposes only.
DoCmd.OpenReport strReport, acViewPreview, , strWhere
End Sub
Please help, Thanks