Moving focus from a parent to a sub form

I

Ian from Action

This ought to be straight forward but Access gives me an error message when using setfocus saying '...cant find the form xxxx referred to in macro or VBA code.....

Does anyone have any ideas why this happens and what I can do to get round it. All I nned to do is move focus from a field populated by a bar scanner to the sub form for data entry/editing.
 
R

Ragnar Midtskogen

This line will move the focus to the field SomeField in the subform
MySubForm:

Forms!MySubForm.Form!SomeField.SetFocus

When referring to controls in a subform you always have to use the Form
property, because that is not the default property of the subform

Ragnar
 

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