First off, I am not a programmer. I'm making a database for work basically because I am the only person who can attempt to understand access. I'm doing pretty good so far.
I found some help with code examples off the web, but I've run into this problem. This code is supposed to create a report between a start date and end date.
as a reference, here's the website I copy and paste the original code: http://members.iinet.net.au/~allenbrowne/casu-08.html
Here's the error: Run-time error '3075': Suntax error (missing operator) in query expression '(Date Entered Between #12/04/1999# And #12/05/2004#)'.
Here's my code:
Private Sub Command4_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 = "Joe Burt Report"
strField = "Date Entered"
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
Can you help?
I found some help with code examples off the web, but I've run into this problem. This code is supposed to create a report between a start date and end date.
as a reference, here's the website I copy and paste the original code: http://members.iinet.net.au/~allenbrowne/casu-08.html
Here's the error: Run-time error '3075': Suntax error (missing operator) in query expression '(Date Entered Between #12/04/1999# And #12/05/2004#)'.
Here's my code:
Private Sub Command4_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 = "Joe Burt Report"
strField = "Date Entered"
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
Can you help?