Setting Focus on Subform

L

Lara

I'm sure this is simple;I must be formatting this wrong.
I am just trying to get a form to set focus on a
particular control on a subform, when a certain button on
the main form is clicked, in VBA. It gives me the
error "Microsoft Access can't find the
form "Demographics2" referred to in a Macro expression or
Visual Basic Code". My format, according to the help
files:

forms!demographics2!company.setfocus

The form is enabled, and visible.
 
P

PC Datasheet

Lara,

Setting focus on a control on a subform from the main form is a two step
process. First you set the focus on the subform control then you set the focus
on the control. Example:
Me!NameOfSubformControl.Setfocus
Me!NameOfSubformControl!NameOfFieldOnSubform.Setfocus

Note that the subform control is not the name of the subform but the name of the
"White Box" for the subform that you see when you open the main form in design
view. Click anywhere on its border, open properties and get its name.
 
L

Lara

Thank you immensely!
-----Original Message-----
Lara,

Setting focus on a control on a subform from the main form is a two step
process. First you set the focus on the subform control then you set the focus
on the control. Example:
Me!NameOfSubformControl.Setfocus
Me!NameOfSubformControl!NameOfFieldOnSubform.Setfocus

Note that the subform control is not the name of the subform but the name of the
"White Box" for the subform that you see when you open the main form in design
view. Click anywhere on its border, open properties and get its name.


--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com








.
 

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