Filter Report

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, I have a report that is based on a very complex query. At the moment
every record is printed and I'm looking for a solution that would filter the
records via a multiselect listbox.

I've seen various methods to achieve this including:-

1. Setting the filter on the report - but the report needs to be already open.
2. Rebuilding the query in code with the new criteria - but this involves
deleting the original query.

Is there a simpler way to do this ie passing the selected list items to the
query criteria?

Thanks
 
If the report is simple enough that can apply a WhereCondition based on the
items in the multi-select list box, see:
Use a multi-select list box to filter a report
at:
http://allenbrowne.com/ser-50.html

If the report has subreports and you enter the limiting values via a form,
you can have the queries of the subreports read the values directly from the
form, by entering criteria such as:
[Forms].[Form1].[StartDate]
It is a good idea to declare these parameters (Parameters on Query menu in
query design view). In fact, it is essential to declare them for crosstab
queries.

If the report is based on stacked queries or has subreports that need the
same criteria applied, you can write the SQL property of the QueryDef
without having to delete it:
dbEngine(0)(0).QueryDefs("MyQuery").SQL = "SELECT ...
 
Back
Top