Open continuous subform to set focus on new record

Access 2010

Hello,
I need to code a continuous subform (frmProductionTracking) to set focus on a new record when the main form (frmJob) is opened.  I've tried some of solutions already posted but nothing seems to work for me.  BTW the control name for the subform frmProductionTracking is ctrProductionTracking.

Thanks for any help.


jnewmanAsked:
Who is Participating?
 
mbizupCommented:
Last thought here before calling it a night.  Since this is Access 2010, make sure that you have enabled macros /vba.

I'll check back in the morning.
0
 
mbizupCommented:
Try this from the open event of the main form:


Me.ctrProductionTracking.SetFocus
DoCmd.RunCommand acCmdRecordsGoToNew

Open in new window

0
 
jnewmanAuthor Commented:
No it didn't work.  What I'll do is update the database to look at.  There is just garbage test data in it anyway.
JSTS.accdb
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
mbizupCommented:
<No it didn't work.>

Can you clarify?

When I open frmJob (double-clicking on it in the Navigation Pane), the focus is immediately set on a new record in the production tracking subform, with the cursor in the Machine Name combo.

If this is not what you are looking for, please clarify where it is going wrong


frmJob.png
0
 
jnewmanAuthor Commented:
That's odd because it doesnt happen for me. Could I be missing some DAO or other VBA plug in?
0
 
mbizupCommented:
Nothing like that's needed, and we are both running Access 2010.

Try adding a message box to the code just for debugging,  simply to ensure that the code is actually running.
0
 
mbizupCommented:
Also, if this is a scaled down sample, does your real database contain any code that may be interfering with the open event?

Also, try this code in the main form's current event.

Did you double click on the form to open it or just switch from design view to form view (which may skip certain events )?
0
 
jnewmanAuthor Commented:
The sample I supplied is the  real database.  I did close and open the db.  As soon as I can I'll try the message box.
0
 
jnewmanAuthor Commented:
Enabling the macro /vba in the trust settings did the trick.  Thanks for the code and advice.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.