Error 3075

whoneeds8

New member
Local time
Today, 12:01
Joined
Jan 26, 2005
Messages
9
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?
 
Thank you very much. Spaces are why I hate code :mad:

I just got back from a meeting, and I'm gonna be changing things up. I'm sure I'll be asking for help alot in the next week
 
Last edited:

Users who are viewing this thread

Back
Top Bottom