filtering query records

  • Thread starter Thread starter Junior
  • Start date Start date
J

Junior

i want to use a single query as a source for several reports with different
criteria-
i know how to reference a cbo or txtbox in a parameter query to return
certain records-
but i don't want to build numerous parameter queries- how can i use a single
query to produce numerous different reports?
 
-----Original Message-----
i want to use a single query as a source for several reports with different
criteria-
i know how to reference a cbo or txtbox in a parameter query to return
certain records-
but i don't want to build numerous parameter queries- how can i use a single
query to produce numerous different reports?


.
base each report on that one query. in each report's Open
event, you can filter the records with a reference to a
cbo or txtbox on your form:

Private Sub Report_Open(Cancel As Integer)

Me.Filter = "QueryFieldName = " & Forms!FormName!
ControlName
Me.FilterOn = True

End Sub
 
i want to use a single query as a source for several reports with different
criteria-
i know how to reference a cbo or txtbox in a parameter query to return
certain records-
but i don't want to build numerous parameter queries- how can i use a single
query to produce numerous different reports?

As long as the field(s) you wish to filter on are all contained in your single
query, you can use the Where parameter of the OpenReport to filter the records.

DoCmd.Openreport "rptMyReport", , , ((SomeField)=" & Me.SomeField & ")"

The Where parameter is the same as the Where clause in a query but without the
WHERE keyword, so you can have multiple criteria -

((SomeField)=" & Me.SomeField & ")"
((SomeField)=" & Me.SomeField & " AND ((AnotherField)=" & Me.AnotherField & ")"
((SomeField) Between " & Me.SomeField & " AND " & Me.AnotherField & ")"

etc

Wayne Gillespie
Gosford NSW Australia
 
Back
Top