On Main Form want to setfocus on Subform

I have a Main form and a subform.  When I open up the main form I would like to put on the OpenForm Event to set focus to the subform.  What would the syntax be for that line of code?

Thanks, Pat
PatKungAsked:
Who is Participating?
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Connect With a Mentor Database ArchitectCommented:
IF ... you want to set focus to a specific control:

Private Sub Form_Load()

Me.YourSubFormControlName.SetFocus
Me.YourSubFormControlName.Form.YourControlName.SetFocus

End Sub

You need both lines in this case.

mx
0
 
Rey Obrero (Capricorn1)Commented:
me.subformName.setfocus
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
In the main form:

Private Sub Form_Load()

Me.YourSubFormControlName.SetFocus


End Sub

mx
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
Rey Obrero (Capricorn1)Commented:
might be better to use the load event of the main form
0
 
clarkscottCommented:
me.YourSubformname.form.PickAnOjectOnthesubform.setfocus

Scott C
0
 
PatKungAuthor Commented:
That is exactly what I needed!
Thanks, Pat
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.