referencing a value

  • Thread starter Thread starter Lez
  • Start date Start date
L

Lez

Hi Guys,

I have an Main form with a tabbed form.

One of the tabs has an order form, the order form has a subform for line
items.

When developing the frmOrderLineItems I have this code for a multi combo
setup, limiting the list to the relevant items:

Like [Forms]![frmOrderLineItems].[Form]![cboProduct]

Which worked fine, however, when I add the sub form to the main frmOrder I
have modified the condition to:

Like [Forms]![frmOrder]![frmOrderLineItems].[Form]![cboProduct]

But this fails, can anyone tell me what the correct referencing should be.

Many thanks
Lez
 
Hi Guys,

I have an Main form with a tabbed form.

One of the tabs has an order form, the order form has a subform for line
items.

When developing the frmOrderLineItems I have this code for a multi combo
setup, limiting the list to the relevant items:

Like [Forms]![frmOrderLineItems].[Form]![cboProduct]

Why the Like operator - which uses wildcards? Will cboProduct contain
wildcards? If not, just use the = operator instead, it's faster.
Which worked fine, however, when I add the sub form to the main frmOrder I
have modified the condition to:

Like [Forms]![frmOrder]![frmOrderLineItems].[Form]![cboProduct]

But this fails, can anyone tell me what the correct referencing should be.

This is the correct syntax IF there is a Subform Control on frmOrder named
frmOrderLineItems. The name of the form *within* that control is irrelevant -
it's the name of the "box" which contains the subform that you need to use.

Also, this will reference the *currently selected record* on the subform;
there might be many records, and from the mainform you can't necessarily
determine which of the many records the user is interested in.
 
Hi John,

No cboProducts does not use wildcards, it the row source manfRefID, I have
tried = but still have the same problem of a parameter box when I try to use
the 2nd combo box, cboProducts has the manfRefID for the subsequent combo
box.

Lez


John W. Vinson said:
Hi Guys,

I have an Main form with a tabbed form.

One of the tabs has an order form, the order form has a subform for line
items.

When developing the frmOrderLineItems I have this code for a multi combo
setup, limiting the list to the relevant items:

Like [Forms]![frmOrderLineItems].[Form]![cboProduct]

Why the Like operator - which uses wildcards? Will cboProduct contain
wildcards? If not, just use the = operator instead, it's faster.
Which worked fine, however, when I add the sub form to the main frmOrder I
have modified the condition to:

Like [Forms]![frmOrder]![frmOrderLineItems].[Form]![cboProduct]

But this fails, can anyone tell me what the correct referencing should be.

This is the correct syntax IF there is a Subform Control on frmOrder named
frmOrderLineItems. The name of the form *within* that control is
irrelevant -
it's the name of the "box" which contains the subform that you need to
use.

Also, this will reference the *currently selected record* on the subform;
there might be many records, and from the mainform you can't necessarily
determine which of the many records the user is interested in.
 
Which worked fine, however, when I add the sub form to the main frmOrder I
have modified the condition to:

Like [Forms]![frmOrder]![frmOrderLineItems].[Form]![cboProduct]

But this fails, can anyone tell me what the correct referencing should be.

You say "this fails". But you don't say in what way it fails. Does it not
retrieve records? retrieve the wrong records? prompts for the parameter (which
suggests that either you don't have a Subform control named frmOrderLineItems
or that it does not contain a control named cboProduct)? Cause you computer to
catch fire?

More details please!
 
Hi John,

I did mention in my first post, it fails by prompting with a parameter box.

I don't understand your comment:

(which suggests that either you don't have a Subform control named
frmOrderLineItems or that it does not contain a control named cboProduct)?

As I mentioned if I open frmOrder and then try to use the combo box they
work fine, so both cboProduct & frmOrderLineItems exist and work as expected

However, as the frmOrders is a subform of frmCustomers, which has a tab form
for the orders page, if I try to use the combo box then I get the parameter
box presented, do I also have to reference the frmCustomers?

Regards
Lez




John W. Vinson said:
Which worked fine, however, when I add the sub form to the main frmOrder I
have modified the condition to:

Like [Forms]![frmOrder]![frmOrderLineItems].[Form]![cboProduct]

But this fails, can anyone tell me what the correct referencing should be.

You say "this fails". But you don't say in what way it fails. Does it not
retrieve records? retrieve the wrong records? prompts for the parameter
(which
suggests that either you don't have a Subform control named
frmOrderLineItems
or that it does not contain a control named cboProduct)? Cause you
computer to
catch fire?

More details please!
 
In order to use form A as a subform on form B, Access creates a subform
container on form B. Depending on how you added form A as a subform, the
name of the subform container may not be the same as the name of the form
being used as a subform. For instance, while you say you're using
frmOrderLineItems as the subform, the name of the subform control could be
something like Child0.

When referring to controls on the subform, you need to refer to the parent
form and the subform control on the parent form. In my example above (where
the subform control was named Child0), the correct reference to control
cboProduct on the subform would be

Like [Forms]![frmOrder]![Child0].[Form]![cboProduct]


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Lez said:
Hi John,

I did mention in my first post, it fails by prompting with a parameter
box.

I don't understand your comment:

(which suggests that either you don't have a Subform control named
frmOrderLineItems or that it does not contain a control named cboProduct)?

As I mentioned if I open frmOrder and then try to use the combo box they
work fine, so both cboProduct & frmOrderLineItems exist and work as
expected

However, as the frmOrders is a subform of frmCustomers, which has a tab
form for the orders page, if I try to use the combo box then I get the
parameter box presented, do I also have to reference the frmCustomers?

Regards
Lez




John W. Vinson said:
Which worked fine, however, when I add the sub form to the main frmOrder
I
have modified the condition to:

Like [Forms]![frmOrder]![frmOrderLineItems].[Form]![cboProduct]

But this fails, can anyone tell me what the correct referencing should
be.

You say "this fails". But you don't say in what way it fails. Does it not
retrieve records? retrieve the wrong records? prompts for the parameter
(which
suggests that either you don't have a Subform control named
frmOrderLineItems
or that it does not contain a control named cboProduct)? Cause you
computer to
catch fire?

More details please!
 
Back
Top