View Full Version : Related table query and DoCmd.OpenReport


Rod C
01-15-2002, 12:42 PM
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.

mjbtx
01-15-2002, 10:38 PM
In my experience, using a filter (your query qryAllDataFields3a)requires all fields to be in the table that the query is based on.