Filter Report from a ComboList list

  • Thread starter Thread starter Raghid Najjar
  • Start date Start date
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.
 
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
 
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] & """ "
 
Back
Top