Query Filtering using Visual Basic

square

New member
Local time
Today, 05:47
Joined
Dec 7, 2004
Messages
7
I am building a series of reports based on different filter settings of the same query.

Rather than save several versions of the query and base each report on its query, I thought I could have a single instance of the query, but then run each report based on VB code that includes the required filter for the general query.

How can I achieve this, experienced Access users?

I'd appreciate any guidance to help me out.

Square
 
Where Clause

When you open your report, it should look like this:

Dim strWhere as String
strWhere = "Company = Toyota" ' or whatever. Do not use SELECT, FROM ect.
DoCmd.OpenReport (your report name), acViewNormal, strWhere
 
The strWhere option's not always the best option, the Where clause of the OpenReport method can be easier to construct
 
The Utmost/Rich,

Thanks for your help so far ...however, I'm still confused about how to filter the query for the report directly from Visual Basic Code.

Could you provide some pointers please?

Many thanks.
 
Something like

DoCmd.OpenReport "rptReminders", acNormal, "", "[ArrID]=[Forms]![OutstInv]![Arrear subform]![ArrID]"

which limits the Report to the record selected on the displayed subform,
The Help file should also have examples of the OpenReport method
 

Users who are viewing this thread

Back
Top Bottom