I have a form that I want to show invoices in a date range. When clicking on the button I get the following error:
Run Time Error 3075 Syntax error (missing operator) in query expression '(Invoice Date Between #08/27/2008 And #08/27/2008#)'
Here is the code associated w/the error:
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 = "SDInvoice"
strField = "Invoice Date"
If IsNull(Me.txtSt artDate) Then
If Not IsNull(Me.txtEn dDate) Then 'End date, but no start.
strWhere = strField & " <= " & Format(Me.txtEn dDate, conDateFormat)
End If
Else
If IsNull(Me.txtEn dDate) Then 'Start date, but no End.
strWhere = strField & " >= " & Format(Me.txtSt artDate, conDateFormat)
Else 'Both start and end dates.
strWhere = strField & " Between " & Format(Me.txtSt artDate, conDateFormat) _
& " And " & Format(Me.txtEn dDate, conDateFormat)
End If
End If
' Debug.Print strWhere 'For debugging purposes only.
DoCmd.OpenRepor t strReport, acViewPreview, , strWhere
What am I missing?
Run Time Error 3075 Syntax error (missing operator) in query expression '(Invoice Date Between #08/27/2008 And #08/27/2008#)'
Here is the code associated w/the error:
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 = "SDInvoice"
strField = "Invoice Date"
If IsNull(Me.txtSt artDate) Then
If Not IsNull(Me.txtEn dDate) Then 'End date, but no start.
strWhere = strField & " <= " & Format(Me.txtEn dDate, conDateFormat)
End If
Else
If IsNull(Me.txtEn dDate) Then 'Start date, but no End.
strWhere = strField & " >= " & Format(Me.txtSt artDate, conDateFormat)
Else 'Both start and end dates.
strWhere = strField & " Between " & Format(Me.txtSt artDate, conDateFormat) _
& " And " & Format(Me.txtEn dDate, conDateFormat)
End If
End If
' Debug.Print strWhere 'For debugging purposes only.
DoCmd.OpenRepor t strReport, acViewPreview, , strWhere
What am I missing?
Comment