Useing subform criteria in a query

A

Ant

I am trying to use the selected data in a sub-form as criteria in a query.
If I type “[Forms]![frm_FormName]![Field_Name]” in the criteria section of
the query, then this works fine in a single form but not if the form is a
sub-Form. I have tried adding the master form at the beginning but without
success.



Any help would be appreciated.
 
D

Danny J. Lesandrini

The syntax is more like this ...

Forms!frmParentForm.ctlSubformControlName.Form!txtControlName
 
G

Guest

You need:

Forms!frmMainForm!SubformCONTROLName.Form!ControlName

Note that the name of the SubformCONTROL may be different from the name of
the Form being used as the Subform (more accurately, being used as the
SourceObject of the SubformControl). You need to check the SubformControl
name in the DesignView of the Main Form.
 
A

Allen Browne

Try:
[Forms].[Form1].[Form2].[Form].[Text1]
where:
- Form1 is the name of the main form,
- Form2 is the name of the subform control, and
- Text1 is the name of the text box in the subform.

For an explanation, see:
Referring to Controls on a Subform
at:
http://allenbrowne.com/casu-04.html
 
A

Ant

Yes that works, easy when you know how!

Thanks!

Van T. Dinh said:
You need:

Forms!frmMainForm!SubformCONTROLName.Form!ControlName

Note that the name of the SubformCONTROL may be different from the name of
the Form being used as the Subform (more accurately, being used as the
SourceObject of the SubformControl). You need to check the SubformControl
name in the DesignView of the Main Form.

--
HTH
Van T. Dinh
MVP (Access)


Ant said:
I am trying to use the selected data in a sub-form as criteria in a
query.
If I type "[Forms]![frm_FormName]![Field_Name]" in the criteria section
of
the query, then this works fine in a single form but not if the form is a
sub-Form. I have tried adding the master form at the beginning but
without
success.



Any help would be appreciated.
 

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