Naming a subform from a main form

G

Guest

I'm having a heck of a time getting to a control on a sub form from a main
form. I use the following convention

Forms![frm MAIN_FORM]![frm SUB_FORM]![CONTROL_NAME]

However when I run the code, I get an error message informing me Access
cannot find the field named [frm SUB_FORM]. Then I tried taking the mainform
out of the line leaving me with
Forms![frm SUB-FORM]![CONTROL_NAME]

Then the message reads can find find the form named frm subform. As far as
I can tell the subform is opened. I can see it.

I'm baffled. Can you help me?
 
S

Steve

Common problem!!

Open your main form in design view. Select the border around the subform.
This is the subform control. Open Properties and Go to the Other tab. Look
at the name property for the subform control. This is what you use in your
expression NOT the name of the subform! Let's say the name is "Jimphily".
The syntax to refer to the control, Control_Name, on your subform is:
Forms![frm MAIN_FORM]!Jimphily.Form![CONTROL_NAME]

By the way, it takes two steps to set focus to a control on a subform from
the main form. You must forst set focus on the subform control and then set
focus on the control on the subform:
Me!Jimphily.SetFocus
Me!Jimphilly.Form![Control_Name].SetFocus

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)
 
M

Marshall Barton

jimphilly said:
I'm having a heck of a time getting to a control on a sub form from a main
form. I use the following convention

Forms![frm MAIN_FORM]![frm SUB_FORM]![CONTROL_NAME]

However when I run the code, I get an error message informing me Access
cannot find the field named [frm SUB_FORM].


Forms![frm MAIN_FORM]![frm SUB_FORM].FORM![CONTROL_NAME]

Note that [frm SUB_FORM] needs to be the name of the subform
control on the main form. The name of the form object being
displayed in the subform control is irrelevant.
 
S

StopThisAdvertising

Steve said:
Common problem!!

Open your main form in design view. Select the border around the subform.
This is the subform control. Open Properties and Go to the Other tab. Look
at the name property for the subform control. This is what you use in your
expression NOT the name of the subform! Let's say the name is "Jimphily".
The syntax to refer to the control, Control_Name, on your subform is:
Forms![frm MAIN_FORM]!Jimphily.Form![CONTROL_NAME]

By the way, it takes two steps to set focus to a control on a subform from
the main form. You must forst set focus on the subform control and then set
focus on the control on the subform:
Me!Jimphily.SetFocus
Me!Jimphilly.Form![Control_Name].SetFocus

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)

Hey Steve,

Look at the stats (Statcounter.com) to see the damage you have done to yourself.
Every time the link is shown, more and more people are reading about you.
http://home.tiscali.nl/arracom/SteveStats.html

Since you have been posting 'nice' the last couple of days the 'answering-machine' stops for now.
We will be watching you though...

ArnoR
 

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