How to set Subform Default Focus

R

Rosemary

I have a main form with a subform. The main form contains only displayed
data; i.e., no control gets the focus. What I want to do is to set the focus
on the subform to the "new" record. I have tried setting the Current event on
the subform (macro: GOTORECORD,,NEW) and it doesn't work correctly. It does
set the focus correctly when the subform is initially displayed. However,
when I try to change the focus to a previous record, the focus automatically
is reset to the "new" record. I have tried other events but none of them seem
to work. I even tried setting an event in the Main form, but I get an error
message stating that the subform isn't opened(?). I also want this to work
whenever I access the next "main form" record.

Your help is greatly appreciated. Thanks in advance.
 
M

Mark A. Sam

Rosemary,

To set the subform to go to a new record, first set the focus on the subform
control then use the GoToRecord method. I don't know the macro syntax, but
the VBA methods are below.

[SubformName].SetFocus
DoCmd.GoToRecord , , acNewRec

Do the same to go to a previous record. First set the focus on the subform
control.

God Bless,

Mark A. Sam
 

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