Related table query and DoCmd.OpenReport

Rod C

Registered User.
Local time
Today, 17:40
Joined
Dec 19, 2001
Messages
41
I have a query that has a main table and a related table, one to many. I am using the following code to open a report and to pass a query name and record selection criteria.
DoCmd.OpenReport "rptAllDataFields1", acPreview, "qryAllDataFields3a", "[County] = 'Deschutes'"

DoCmd.OpenReport "rptAllDataFields1", acPreview, "qryAllDataFields3a", "[Component] = 'ITS'"

The first syntax works, the criteria, "[County] = 'Deschutes'", is a field in the main table.

The second syntax does not work, the criteria, "[Component] = 'ITS'", is a field in the related table. It gives me an “Enter Parameter Value” pop-up that wants “Component”.

The query works if you put the criteria "ITS" in the Criteria row just not when it is passed with the code.
 
In my experience, using a filter (your query qryAllDataFields3a)requires all fields to be in the table that the query is based on.
 

Users who are viewing this thread

Back
Top Bottom