Set focus to a subform

Deonh911

Registered User.
Local time
Today, 19:52
Joined
Mar 5, 2013
Messages
30
Hello all

Was wondering if any one can help me

If i open a form with a sub form on can i open it so that the focus go directly to a control on a sub form.

I have tried to do it with a macro on the on open event to go to control but it comes up that the control don't exists on the sub form

i am using access 2010

Thanks in advance for your help in the matter
 
Try to move your code for the open event to the form's load event.
If it doesn't help show your code.
 
Thank You JHB will give it a try as soon as i can get to my Pc :)
 
Hello JHB

Ok i have done what you said it still give me the same problem but the error code has changed.

I am attaching my db for you so you can see what i have done it will be the first button on main form that take me to the page i want maybe you can see what i am doing wrong

Deon
 
You need to do it in two steps - first set the focus to the subform, and the afterwards to the control in the subform.
I've change your macro to a Event Procedure.
The database is attached.
 

Attachments

the problem is that the subform does not exist directly - it exists as an object within the main form

so you might need the FORM qualifier in the statement - eg this sort of syntax, where subform is the name of the control on the main form that holds the subform.

forms!mainform!subform.FORM!fieldname.setfocus

see help for "referring to a subform"
 

Users who are viewing this thread

Back
Top Bottom