open and filter report from vba (1 Viewer)

Mr.K

Registered User.
Local time
Today, 13:18
Joined
Jan 18, 2006
Messages
104
I have a report based on a query. I would like to be able to open that report from an OnClick event but limit the query to a particular value for one of the fields. The value must be supplied from within the vba code. So the logic in the code would be something like this:

Code:
open report where myquery.somefiled=myCalculatedValue()

it's probably some simple solution, but since I'm learning Access by reading forums and googling - there are many gaps in my knowledge.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 12:18
Joined
Aug 30, 2003
Messages
36,118
Look at the wherecondition argument of DoCmd.OpenReport.
 

Mr.K

Registered User.
Local time
Today, 13:18
Joined
Jan 18, 2006
Messages
104
pbaldy said:
Look at the wherecondition argument of DoCmd.OpenReport.
Thanks; that will do the job and as i said - gaps in basic knowledge.

Question: Isn't it more db efficient (on the background) to load the query already filtered rather then to open it with all records and then filter the report? Or is it something I really shouldn't worry about. ~ just wondering.
 

Users who are viewing this thread

Top Bottom