Subform, combo box, parameter query?

  • Thread starter BonnieW via AccessMonster.com
  • Start date

B

BonnieW via AccessMonster.com

Hi everyone!

I have an unbound form. On that form is a tab control, and on that tab
control is subform and another subform.
How it's laid out:
____________
FORM (unbound)
-tab
--subform (bound) (combo box 1)
---subsubform (bound) (combo box 2)
_____________

On my subsubform, I have a combo box which references a combo box in the
subform- in the subform you choose a route, in the subsubform you choose a
stop. When I open up my subform directly, everything works peachy-keen: the
combo box on the subsubform populates correctly. However, when I open FORM,
I get an "Enter parameter value: (name of combo box on subform that is being
referenced)."

The SQL behind my query:
SELECT tblAnuraPoints.AnC_Site_ID_KEY_NEW, tblAnuraPoints.AnR_Route_ID_NEW,
tblAnuraPoints.AnC_Point_Name, tblAnuraPoints.Active, tblAnuraPoints.Sequence
FROM tblAnuraPoints
WHERE (((tblAnuraPoints.AnR_Route_ID_NEW)=[Forms]![sfrmAnuraVisit]![cboRoute])
AND ((tblAnuraPoints.Active)=Yes))
ORDER BY tblAnuraPoints.AnC_Point_Name, tblAnuraPoints.Sequence;

So, why is it doing this, and how can I get it to just *work*? Thanks in
advance!
 
Ad

Advertisements

G

George Nicholson

...[Forms]![sfrmAnuraVisit]![cboRoute])
The Forms collection is comprised only of open *parent* forms. Subforms are
not part of the Forms collection. Therefore, you can almost never refer to a
subform by name, you need to refer to the control containing the subform.
(Wizards might give the container control the same name as the subform, but
this can be confusing since they are not the same thing. It's important to
keep the distinction in mind.)

You'll need to change the reference to something like:

[Forms]![myParentForm]![NameOfControlThatContainsTheSubform]![cboRoute]

more examples:
Refer to Form and Subform properties and controls
http://mvps.org/access/forms/frm0031.htm


HTH,
 
B

BonnieW via AccessMonster.com

Figured it out! I just had to change combo box 2's rowsource query to:
SELECT tblAnuraPoints.AnC_Site_ID_KEY_NEW, tblAnuraPoints.AnR_Route_ID_NEW,
tblAnuraPoints.AnC_Point_Name, tblAnuraPoints.AnC_Active, tblAnuraPoints.
AnC_Sequence
FROM tblAnuraPoints
WHERE (((tblAnuraPoints.AnR_Route_ID_NEW)=[Forms]![frmHerps]![sfrmAnuraVisit]!
[cboRoute]) AND ((tblAnuraPoints.AnC_Active)=Yes))
ORDER BY tblAnuraPoints.AnC_Point_Name, tblAnuraPoints.AnC_Sequence;

Thanks!
Hi everyone!

I have an unbound form. On that form is a tab control, and on that tab
control is subform and another subform.
How it's laid out:
____________
FORM (unbound)
-tab
--subform (bound) (combo box 1)
---subsubform (bound) (combo box 2)
_____________

On my subsubform, I have a combo box which references a combo box in the
subform- in the subform you choose a route, in the subsubform you choose a
stop. When I open up my subform directly, everything works peachy-keen: the
combo box on the subsubform populates correctly. However, when I open FORM,
I get an "Enter parameter value: (name of combo box on subform that is being
referenced)."

The SQL behind my query:
SELECT tblAnuraPoints.AnC_Site_ID_KEY_NEW, tblAnuraPoints.AnR_Route_ID_NEW,
tblAnuraPoints.AnC_Point_Name, tblAnuraPoints.Active, tblAnuraPoints.Sequence
FROM tblAnuraPoints
WHERE (((tblAnuraPoints.AnR_Route_ID_NEW)=[Forms]![sfrmAnuraVisit]![cboRoute])
AND ((tblAnuraPoints.Active)=Yes))
ORDER BY tblAnuraPoints.AnC_Point_Name, tblAnuraPoints.Sequence;

So, why is it doing this, and how can I get it to just *work*? Thanks in
advance!
 
Ad

Advertisements

B

BonnieW via AccessMonster.com

Thanks! I was just missing the reference to the parent form.


George said:
...[Forms]![sfrmAnuraVisit]![cboRoute])
The Forms collection is comprised only of open *parent* forms. Subforms are
not part of the Forms collection. Therefore, you can almost never refer to a
subform by name, you need to refer to the control containing the subform.
(Wizards might give the container control the same name as the subform, but
this can be confusing since they are not the same thing. It's important to
keep the distinction in mind.)

You'll need to change the reference to something like:

[Forms]![myParentForm]![NameOfControlThatContainsTheSubform]![cboRoute]

more examples:
Refer to Form and Subform properties and controls
http://mvps.org/access/forms/frm0031.htm

HTH,
Hi everyone!
[quoted text clipped - 31 lines]
So, why is it doing this, and how can I get it to just *work*? Thanks in
advance!
 

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