Set Focus

H

Howard

I need the code to set focus on a field in a subform. My
main form is called Customer, the subform is called
Components, and the field I want to put the focus on is
called Date. What is happening in my application is I'm
trying to use a pop-up calendar control. I have the
control set as invisible. Using the events in the form,
when I enter the field, I make the calendar control
visible, and when I exit the field, I make the calendar
control invisible. The problem is after I make the
calendar control invisible, the focus goes back to the
first field in the form instead of the next field in the
tab order. Therefore, I want to set the focus to the
proper field. Thanks!
-Howard
 
K

Ken Snell

To set focus to a control in a subform, first set focus to the subform
control (the control that holds the subform), and then set focus to the
control on that subform:

Me.Subform.SetFocus
Me.Subform.Form.ControlName.SetFocus
 
K

Ken Snell

Subform needs to be replaced by the name of the subform control (the control
that holds the subform, which name may or may not be the same name as that
control's SourceObject). Also, if the code that runs these steps is in
another form's module, replace Me with the full reference to that other
form:
Forms("Formname")!Subform.SetFocus
Forms("Formname")!Subform.Form.ControlName.SetFocus
 

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