Find data on main form from subform code

  • Thread starter mattc66 via AccessMonster.com
  • Start date
M

mattc66 via AccessMonster.com

Hi All,

I have some code in my subform. I am would like to run an if statement like
below. If on the main form a check box is checked then... However my syntax
is wrong and the code cant see my main form object. Can anyone help.

If Forms![frmPO_Lookup].Form!ckref = True Then
....
Thanks
 
B

boblarson

Most likely your form (frmPO_Lookup) is actually in a subform container
control that is NOT named frmPO_Lookup. When using code to refer to
subforms, you need to refer to the subform CONTAINER name, not the subform
name (although it can be the subform name if the container has the same name).

See here for more explanation about subforms:

http://www.btabdevelopment.com/main...rhowtoreferencesubforms/tabid/76/Default.aspx

--
Bob Larson

Free Tutorials and Samples at http://www.btabdevelopment.com

__________________________________
 
B

Beetle

If the code is in the subform and the ckref control is on the main form;

If Me.Parent!ckref = True Then
 
B

boblarson

Good point - missed that one :)
--
Bob Larson

Free Tutorials and Samples at http://www.btabdevelopment.com

__________________________________


Beetle said:
If the code is in the subform and the ckref control is on the main form;

If Me.Parent!ckref = True Then
--
_________

Sean Bailey


mattc66 via AccessMonster.com said:
Hi All,

I have some code in my subform. I am would like to run an if statement like
below. If on the main form a check box is checked then... However my syntax
is wrong and the code cant see my main form object. Can anyone help.

If Forms![frmPO_Lookup].Form!ckref = True Then
....
Thanks
 

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