Useing subform criteria in a query

  • Thread starter Thread starter Ant
  • Start date Start date
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.
 
The syntax is more like this ...

Forms!frmParentForm.ctlSubformControlName.Form!txtControlName
 
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.
 
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
 
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.
 
Back
Top