Query Based on Main and SubForm ID Fields Not Working

W

Wayne

I’m trying to create a query that will show me only the records that
match the current ID fields on the frmTest and subform frmTestSub.
I’ve tried several entries in the Criteria field but the testSubID
keeps popping up the “Enter Parameter Value.” What do I have to type
in the TestSubID field to get the query to work correctly?

Here is the SQL view:

SELECT tblTest.TestID, tblTest.Name, tblTestSub.TestSubID,
tblTestSub.TestID, tblTestSub.Auto
FROM tblTest INNER JOIN tblTestSub ON tblTest.TestID =
tblTestSub.TestID
WHERE (((tblTest.TestID)=[Forms]![frmTest]![txtTestID]) AND
((tblTestSub.TestSubID)=[Forms]![frmTestSub]![txtTestSubID]));
 
M

Marshall Barton

Wayne said:
I’m trying to create a query that will show me only the records that
match the current ID fields on the frmTest and subform frmTestSub.
I’ve tried several entries in the Criteria field but the testSubID
keeps popping up the “Enter Parameter Value.” What do I have to type
in the TestSubID field to get the query to work correctly?

Here is the SQL view:

SELECT tblTest.TestID, tblTest.Name, tblTestSub.TestSubID,
tblTestSub.TestID, tblTestSub.Auto
FROM tblTest INNER JOIN tblTestSub ON tblTest.TestID =
tblTestSub.TestID
WHERE (((tblTest.TestID)=[Forms]![frmTest]![txtTestID]) AND
((tblTestSub.TestSubID)=[Forms]![frmTestSub]![txtTestSubID]));


When referencing a control/field in a subform, you need to
go through the main form and its subform control.

tblTestSub.TestSubID)=Forms!frmTest!frmTestSub!txtTestSubID

Note that frmTestSub in the above is the name of the subform
**control** on the main form. The name of the control might
or might not be the same as the name of the form object that
is displayed in the subform control.
 
W

Wayne

Wayne said:
I’m trying to create a query that will show me only the records that
match the current ID fields on the frmTest and subform frmTestSub.
I’ve tried several entries in the Criteria field but the testSubID
keeps popping up the “Enter Parameter Value.”  What do I have to type
in the TestSubID field to get the query to work correctly?
Here is the SQL view:
SELECT tblTest.TestID, tblTest.Name, tblTestSub.TestSubID,
tblTestSub.TestID, tblTestSub.Auto
FROM tblTest INNER JOIN tblTestSub ON tblTest.TestID =
tblTestSub.TestID
WHERE (((tblTest.TestID)=[Forms]![frmTest]![txtTestID]) AND
((tblTestSub.TestSubID)=[Forms]![frmTestSub]![txtTestSubID]));

When referencing a control/field in a subform, you need to
go through the main form and its subform control.

tblTestSub.TestSubID)=Forms!frmTest!frmTestSub!txtTestSubID

Note that frmTestSub in the above is the name of the subform
**control** on the main form.  The name of the control might
or might not be the same as the name of the form object that
is displayed in the subform control.

Works great! Thanks Marsh.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top