Report form multitasking

NWGal
2StarLounger
Posts: 198
Joined: 21 Aug 2011, 02:32

Report form multitasking

Post by NWGal »

To open a specific report from a list and filter the data for that report by the location I choose from a second listbox.
I have the following code in the onclick event of a button.

Code: Select all

Private Sub Open_Report_Click()
Dim strWhere As String
    If IsNull(Me.lstRpt) Then
        Me.lstRpt.SetFocus
        MsgBox "Please select a report, then try again.", vbExclamation
        Exit Sub
    End If
    If Not IsNull(Me.lstLoc) Then
        strWhere = "LocationName = " & Chr(34) & Me.lstLoc & Chr(34)
    End If
    DoCmd.OpenReport ReportName:=Me.lstRpt, View:=acViewPreview, _
        WhereCondition:=strWhere
End Sub
One of the reports is a contact list, and I would like to filter it by roleid, so I added a list box for that as well on the form. I can't quite figure out how to add this piece to the code. In short, when I click on contact report, I would like to have it pull only staff, or only volunteers etc, and if possible, have an all category as well, though I am unsure how to do that.
Thanks

User avatar
HansV
Administrator
Posts: 78620
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Report form multitasking

Post by HansV »

Do you want to filter the contact report by location AND role, or only by role?
Best wishes,
Hans