Problem passing a value from a form to query

D

DV

I'm attempting to pass a value from a sub-form to a query. In the field
criteria I have the following:

Forms![xfrm Research Database Subform]![SYSTEM].

When I attempt to run the query from using a command button, the query can't
find the value of the SYSTEM field above. The field is a combo box.

I get a "enter Parameter Value" pop-up with the label- Forms!xfrm Research
Database prompting me for input. This is the name of the form that the
subform from above is linked to.

I even tried passing a value from the main form "xfrm Research Database" as
a test, and had similar results.

The funny thing is that if I enter a valid value for "SYSTEM" the query will
run as expected, but I obviously want to pick the value direct from the form.
 
G

George Nicholson

You can't refer to a subform using the Forms collection. The Forms
collection consists only of open Forms and forms used as subforms aren't
included.

You can only access subforms via the Form property of the subform control
acting as their container.

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

Note that Form is the default property of a subform control so it can
usually be omitted, as long as you get everything else right :).

HTH,
 
D

DV

You lost me on this one George - "Form property of the subform control
acting as their container."

Where do I find the form property of the subform control. Or to start, do I
have to change the main form or sub form?

George Nicholson said:
You can't refer to a subform using the Forms collection. The Forms
collection consists only of open Forms and forms used as subforms aren't
included.

You can only access subforms via the Form property of the subform control
acting as their container.

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

Note that Form is the default property of a subform control so it can
usually be omitted, as long as you get everything else right :).

HTH,
--
George Nicholson

Remove 'Junk' from return address.


DV said:
I'm attempting to pass a value from a sub-form to a query. In the field
criteria I have the following:

Forms![xfrm Research Database Subform]![SYSTEM].

When I attempt to run the query from using a command button, the query
can't
find the value of the SYSTEM field above. The field is a combo box.

I get a "enter Parameter Value" pop-up with the label- Forms!xfrm Research
Database prompting me for input. This is the name of the form that the
subform from above is linked to.

I even tried passing a value from the main form "xfrm Research Database"
as
a test, and had similar results.

The funny thing is that if I enter a valid value for "SYSTEM" the query
will
run as expected, but I obviously want to pick the value direct from the
form.
 
K

KARL DEWEY

Refer this way to control on a subform --
[Forms![YourMainFormName]![xfrm Research Database Subform]![SYSTEM]

DV said:
You lost me on this one George - "Form property of the subform control
acting as their container."

Where do I find the form property of the subform control. Or to start, do I
have to change the main form or sub form?

George Nicholson said:
You can't refer to a subform using the Forms collection. The Forms
collection consists only of open Forms and forms used as subforms aren't
included.

You can only access subforms via the Form property of the subform control
acting as their container.

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

Note that Form is the default property of a subform control so it can
usually be omitted, as long as you get everything else right :).

HTH,
--
George Nicholson

Remove 'Junk' from return address.


DV said:
I'm attempting to pass a value from a sub-form to a query. In the field
criteria I have the following:

Forms![xfrm Research Database Subform]![SYSTEM].

When I attempt to run the query from using a command button, the query
can't
find the value of the SYSTEM field above. The field is a combo box.

I get a "enter Parameter Value" pop-up with the label- Forms!xfrm Research
Database prompting me for input. This is the name of the form that the
subform from above is linked to.

I even tried passing a value from the main form "xfrm Research Database"
as
a test, and had similar results.

The funny thing is that if I enter a valid value for "SYSTEM" the query
will
run as expected, but I obviously want to pick the value direct from the
form.
 

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