Filtering a Report by Date + 1 Field

JVermast

Registered User.
Local time
Today, 06:16
Joined
Jun 15, 2005
Messages
70
I have a report that uses the code found below the filter the report by date. I have no idea where I found the code as I made this a long time ago, but now it has been requested that I add another filter to the actual report in addition to the date filter.

This isn't the same setup as I have been doing for numerous other reports (using a query with criteria) and I have no idea how I can change this code to include another filter (strStatus) to the report.

Any help would be greatly appreciated.

Code:
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 = "RefurbDate"
    strField = "dtStart"

    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
 
Alright I got this figured out.I just took the code from the original query and translated it to the criteria that could be used for a query. Worked perfectly.
 

Users who are viewing this thread

Back
Top Bottom