Need help getting query to reference a field in a subform

  • Thread starter Thread starter Mike Daniska
  • Start date Start date
M

Mike Daniska

I am trying to run a query using a specific field in a subform as the
criteria. The query is displaying one combo box from the Form, as well
as several fields from its own subform.

My Form name is: FormGrantManagement
My Subform name is: TableMOA subform
My Subform's subform is: TableCostReports
The field in the subform I want to reference is: MOAID

I have found other help topics that lead me to think that a criteria
along the lines of [Forms]![FormGrantManagement]![TableMOA subform]!
[Form]![MOAID] is what I need to use, and I have tried multiple
variations of this but without success. When I run this query in my
form it prompts me with a parameter query displaying my criteria. If I
type in an actual MOAID number, then the query works, if I click
"Okay" without typing anything in the parameter query I get a query
without any data. Any ideas?

Thanks!

Mike
 
Mike said:
I am trying to run a query using a specific field in a subform as the
criteria. The query is displaying one combo box from the Form, as well
as several fields from its own subform.

My Form name is: FormGrantManagement
My Subform name is: TableMOA subform
My Subform's subform is: TableCostReports
The field in the subform I want to reference is: MOAID

I have found other help topics that lead me to think that a criteria
along the lines of [Forms]![FormGrantManagement]![TableMOA subform]!
[Form]![MOAID] is what I need to use, and I have tried multiple
variations of this but without success. When I run this query in my
form it prompts me with a parameter query displaying my criteria. If I
type in an actual MOAID number, then the query works,


Form is a **property** of subform controls, so that should
be:

Forms!FormGrantManagement![TableMOA subform].Form!MOAID

If that still generates a prompt, check the spelling of each
name carefully.
 
Mike,

You refer to two subforms. Is [TableCostReports] a subform within [tableMOA
subform]? Which of these subforms contains the MOAID field?

Also, you need to use the name of the subform control, not the name of the
object that is the subform. So it might look like:

Forms!FormGrantManagement![TableMOA subform].form.MOAID

as Marshall stated, but if MOAID is on the [TableCostReports] subform, then
it might look like:

Forms!FormGrantManagement![TableMOA
subform].form.[tableCostReports].form.MOAID

the general syntax should look like:

Forms!MainFormName!subformControlName.form.controlname
or
Forms!MainFormName!sub1CtrlName.form.sub2CtrlName.form.controlname
 
Back
Top