I have a main form with 4 subforms and would like to know how I can move the focus from the main form to the subform without the mouse point and click. My database is in access 2007 and I am using Vista.
I have a main form with 4 subforms and would like to know how I can move the focus from the main form to the subform without the mouse point and click. My database is in access 2007 and I am using Vista.
try:
Code:me.subformcontrol.form.setfocus me.subformcontrol.form.controls("control name").setfocus
Thanks for your reply. When I use your suggested code focus is lost from the control in the main form but is not moved to the control I specified in the subform. Any suggestiond?
make sure the first line's "subform" part of the syntax references the subform's control and not the name of the actual form. that, above any other, is the mistake that is always made. surprisingly, it is also one of the few concepts in access that people never understand, as it is asked over and over again...
I usedthe subform's control as you suggested and shown in the code
Me.Visits_Subform.Form.SetFocus
Me.Visits_Subform.Form.Controls("Bags of Food").SetFocus
It removes the focus from the control in the main form but does not set the focus on the "bags of food" control in the visits subform. If I press the Tab key it then shifts the focus to a subform which is the last tabstop on the main form. What am I doing wrong?
try:I may have been wrong about using the word "form" in the first line. it's been eons since I've given advice on how to do this. I tested this, and it works fine:Code:Me.Visits_Subform.SetFocus Me.Visits_Subform.Form.Controls
set focus to the subform control, then focus to one of the controls on that subform.
thank you very much. this did the trick.