SetFocus with Subform

DanG

Registered User.
Local time
Today, 04:41
Joined
Nov 4, 2004
Messages
477
I have a form with a button that when clicked triggers "find" in a field that is located on the form...

Code:
Private Sub Command23_Click()
DoCmd.GoToControl "last name"
DoCmd.RunCommand acCmdFind

End Sub [code]

When the record is found and the user presses "esc" to close the find box  I would like to set the focus in a field located in the subform...

[code] Private Sub Form_Current()
Me.LT2DataEntrySubform1.Form!QRt.SetFocus
End Sub [code]

Problem is after the user presses "Esc" both the field on the form that is used to seach on and the field in the subform that I set the focus on have the focus. Yes...both fields have focus and unless the user clicks on some other field no dataentry can be done.

Any suggestions would be appreciated.
Thanks
 
When setting focus to a control in a sub form you must first set the focus to the subform and then to the control...

Me!LT2DataEntrySubform1.SetFocus
Me!LT2DataEntrySubform1.Form!QRt.SetFocus
 
That did it!

Thank you for the lesson.
 

Users who are viewing this thread

Back
Top Bottom