D
Dcbrown428
I have read multiple posts and tried various tutorials, but have been unable
to get my form named "Report Date Range" to complete the query to rerieve the
report. I can open the report by running the query, but run in to problems
with code for form. I copied this format from Allen Browne's website. I get
error message "Runtime error '3075': Syntaxerror (missing operator) in query
expression '(closing date Between #10/01/2005# and #11/01/2005#)'.
When I click on Debug the "DoCmd.OpenReport..." line is highlighted. HELP!
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 = "Contingency Report"
strField = "Closing 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
End If
' Debug.Print strWhere 'For debugging purposes only.
DoCmd.OpenReport strReport, acViewPreview, , strWhere
to get my form named "Report Date Range" to complete the query to rerieve the
report. I can open the report by running the query, but run in to problems
with code for form. I copied this format from Allen Browne's website. I get
error message "Runtime error '3075': Syntaxerror (missing operator) in query
expression '(closing date Between #10/01/2005# and #11/01/2005#)'.
When I click on Debug the "DoCmd.OpenReport..." line is highlighted. HELP!
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 = "Contingency Report"
strField = "Closing 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
End If
' Debug.Print strWhere 'For debugging purposes only.
DoCmd.OpenReport strReport, acViewPreview, , strWhere