Focus set to subform control

  • Thread starter Thread starter Darrell
  • Start date Start date
D

Darrell

The following code is in the AfterUpdate event of a combo box on a main
form:

Private Sub comboboxOnMainForm_AfterUpdate()

'Enable subform
Me!subform.Enabled = True

Me!subform!control1 = "Value1"
Me!subform!control2 = "Value2"
Me!subform!control3 = "Value3"
Me!subform!control4.SetFocus

End Sub


The above code, running on a main form's combo box, executes without
complaint. But, the focus ends up squarely in the original combo box.
There is not code that runs after this. How and why does the SetFocus
executed in the last line seem to have no effect? And, obviously, how
can I remedy this?

Thank you in advance for any help!

Darrell
 
In
Darrell said:
The following code is in the AfterUpdate event of a combo box on a
main form:

Private Sub comboboxOnMainForm_AfterUpdate()

'Enable subform
Me!subform.Enabled = True

Me!subform!control1 = "Value1"
Me!subform!control2 = "Value2"
Me!subform!control3 = "Value3"
Me!subform!control4.SetFocus

End Sub


The above code, running on a main form's combo box, executes without
complaint. But, the focus ends up squarely in the original combo box.
There is not code that runs after this. How and why does the SetFocus
executed in the last line seem to have no effect? And, obviously, how
can I remedy this?

Thank you in advance for any help!

Darrell

The subform and the main form both have their own "active controls".
You have to both set focus to the control on the subform and set focus
to the subform itself:

Me!subform.SetFocus
Me!subform!control4.SetFocus
 
Back
Top