R
Ruth
I created a form to use as a "print menu" for a report. You can select
the date range (txtStartDate and txtStopDate). I have this part of the
code working. However, I also need to be able to filter based on the
job flag: [Flag] with value of 1, 2 or 3-- OR show all (still applying
the date range). I created a list box on the form and named it
[ReportFilter]. It's bound to the first column (hidden) with 0 for
All, 1, 2 and 3 to correspond with the Flag names. I can't figure out
how to get All records to show on top of not being able to incorporate
with the above date range.
Here's what I have so far. How would I modify?
Private Sub btnViewRpt_Click()
Dim strReport As String
Dim strField As String
Dim strWhere As String
Const conDateFormat = "\#mm\/dd\/yyyy\#"
strReport = "rptJobsbyCustInclCanc_All"
strField = "Callin"
If IsNull(Me.txtStartDate) Then
If Not IsNull(Me.txtEndDate) Then
strWhere = strField & " <= " & Format(Me.txtEndDate,
conDateFormat)
End If
Else
If IsNull(Me.txtEndDate) Then
strWhere = strField & " >= " & Format(Me.txtStartDate,
conDateFormat)
Else
strWhere = strField & " Between " &
Format(Me.txtStartDate, conDateFormat) _
& " And " & Format(Me.txtEndDate, conDateFormat)
End If
End If
' Debug.Print strWhere
DoCmd.OpenReport strReport, acViewPreview, , strWhere
End Sub
Any help anyone can offer will be greatly appreciated!
Thanks,
Ruth
the date range (txtStartDate and txtStopDate). I have this part of the
code working. However, I also need to be able to filter based on the
job flag: [Flag] with value of 1, 2 or 3-- OR show all (still applying
the date range). I created a list box on the form and named it
[ReportFilter]. It's bound to the first column (hidden) with 0 for
All, 1, 2 and 3 to correspond with the Flag names. I can't figure out
how to get All records to show on top of not being able to incorporate
with the above date range.
Here's what I have so far. How would I modify?
Private Sub btnViewRpt_Click()
Dim strReport As String
Dim strField As String
Dim strWhere As String
Const conDateFormat = "\#mm\/dd\/yyyy\#"
strReport = "rptJobsbyCustInclCanc_All"
strField = "Callin"
If IsNull(Me.txtStartDate) Then
If Not IsNull(Me.txtEndDate) Then
strWhere = strField & " <= " & Format(Me.txtEndDate,
conDateFormat)
End If
Else
If IsNull(Me.txtEndDate) Then
strWhere = strField & " >= " & Format(Me.txtStartDate,
conDateFormat)
Else
strWhere = strField & " Between " &
Format(Me.txtStartDate, conDateFormat) _
& " And " & Format(Me.txtEndDate, conDateFormat)
End If
End If
' Debug.Print strWhere
DoCmd.OpenReport strReport, acViewPreview, , strWhere
End Sub
Any help anyone can offer will be greatly appreciated!
Thanks,
Ruth