T
TotallyConfused
I am trying to create a form that will collect parameters for a Report. In
searching for help on this I came across Allen Brownes Access Tip, "Limiting
a Report to a Date Range". However, the code below works fine for one date.
My report has 4 date parameters that need to be filled by the form. How can
this be achieved using Mr. Browne's code? I have an Appt date, CareStart
Date and CareEndDate, HospStart Date and HospEndDate and ServiceStartDate and
ServiceEndDate.
Any help will be greatly appreciated. Thank you.
Private Sub OK_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 = "rpt PPC Fax Cover Sheet"
strField = "text109"
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
searching for help on this I came across Allen Brownes Access Tip, "Limiting
a Report to a Date Range". However, the code below works fine for one date.
My report has 4 date parameters that need to be filled by the form. How can
this be achieved using Mr. Browne's code? I have an Appt date, CareStart
Date and CareEndDate, HospStart Date and HospEndDate and ServiceStartDate and
ServiceEndDate.
Any help will be greatly appreciated. Thank you.
Private Sub OK_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 = "rpt PPC Fax Cover Sheet"
strField = "text109"
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