L
louonline
Hi all,
I copied the CODE below from Allen Browne's website. (thanks Allen)
It works Ok except for one small problem.
If the startdate is say 3-Jan-2006 and enddate is 15-Jan-2006 the
report will only return info for 3-Jan-2006 to 14-Jan-2006, NOT
15-JAN-2006.
To get info up to 15-Jan-2006 I have to enter 16-Jan-2006 as the
enddate.
I can live with this because I know how it works but I would like to
have a "what-you-see-is-what-you-get" for other users.
Is there any way to fix this so it will include info for the ENTERED
enddate (15-Jan-2006)?
Regards,
Lou
---------------
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
I copied the CODE below from Allen Browne's website. (thanks Allen)
It works Ok except for one small problem.
If the startdate is say 3-Jan-2006 and enddate is 15-Jan-2006 the
report will only return info for 3-Jan-2006 to 14-Jan-2006, NOT
15-JAN-2006.
To get info up to 15-Jan-2006 I have to enter 16-Jan-2006 as the
enddate.
I can live with this because I know how it works but I would like to
have a "what-you-see-is-what-you-get" for other users.
Is there any way to fix this so it will include info for the ENTERED
enddate (15-Jan-2006)?
Regards,
Lou
---------------
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