Query Parameters that use subform fields

G

Geof Wyght

Hello,
I know how to create a query with a parameter that uses a
form field, as in: Where ID = [Forms]![Form1]![txtID].
But can I construct a Where clause that refers to a
control on a subform as in: Where ID = [Forms]![Form1]!
[subForm1]![txtID] ?? When I run the query it doesn't
appear to recognize this construct.
Thanks.
Geof Wyght
 
J

John Vinson

Hello,
I know how to create a query with a parameter that uses a
form field, as in: Where ID = [Forms]![Form1]![txtID].
But can I construct a Where clause that refers to a
control on a subform as in: Where ID = [Forms]![Form1]!
[subForm1]![txtID] ?? When I run the query it doesn't
appear to recognize this construct.
Thanks.
Geof Wyght

The syntax is a bit goofy. The Subform is not open in its own right;
you need to use the Name property *of the Subform control* on the
mainform (which may or may not be the same as the Name of the form
within that subform control):

=Forms!Form1![Subform1].Form!txtID

The .Form is supposedly the default Property of a Subform control, and
therefore optional, but I find it helpful to routinely include it.

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
G

Geof Wyght

Thanks, John. That looks like VBA syntax though. I'm
looking for a Where clause of a parameter query, where I
have read that one has to use the bang syntax, not the
dot syntax.
Geof Wyght.
-----Original Message-----
Hello,
I know how to create a query with a parameter that uses a
form field, as in: Where ID = [Forms]![Form1]![txtID].
But can I construct a Where clause that refers to a
control on a subform as in: Where ID = [Forms]![Form1]!
[subForm1]![txtID] ?? When I run the query it doesn't
appear to recognize this construct.
Thanks.
Geof Wyght

The syntax is a bit goofy. The Subform is not open in its own right;
you need to use the Name property *of the Subform control* on the
mainform (which may or may not be the same as the Name of the form
within that subform control):

=Forms!Form1![Subform1].Form!txtID

The .Form is supposedly the default Property of a Subform control, and
therefore optional, but I find it helpful to routinely include it.

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps

.
 
V

Van T. Dinh

The DOT operator should work fine in this case. In fact, you can't use the
BANG operator since "Form" is a Property of the SubformCONTROL.
 

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