Filter Report from a ComboList list

R

Raghid Najjar

I created a report that i want to Filter by a certain criteria (Project
Category).
I want to be able to have a dragdown list (on a seprate form) that is
limited to this criteria.
I also want it to generate the report filtered by my chosen category.
 
G

golfinray

You need to use the WHERE clause of the docmd.openreport command. Here is an
example I use:
Private Sub combo2_Click()
Dim strWhere As String
Dim stDocument As String
stDocument = "06-07 active projects"
strWhere = "1=1 "
If Not IsNull(Me.Combo2) Then
strWhere = strWhere & " And [Area]=""" & _
Me.Combo2 & """"
End If
DoCmd.OpenReport stDocument, acPreview, , strWhere
DoCmd.Close acForm, "area form 1", acSaveNo
You establish WHERE to open the report and what report to open. The actual
filter is the Strwhere command. Here I am filter on area.


End Sub
 
M

Marshall Barton

I created a report that i want to Filter by a certain criteria (Project
Category).
I want to be able to have a dragdown list (on a seprate form) that is
limited to this criteria.
I also want it to generate the report filtered by my chosen category.


In the code for the button that opens the report change the
OpenReport line to something more like:

DoCmd.OpenReport "report name", acViewPreview, , "[Project
Category] = """ & Me.[the combo box] & """ "
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top