Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set (Keep) Focus of combo box in After Update event

Status
Not open for further replies.

gavin31

Programmer
Mar 14, 2004
28
IE
I have the following code in the After Update event of a combo box on a form.

Private Sub jobNumber_AfterUpdate()

If (<<condition 1>>) Then
MsgBox "Please choose different job Number"
Me.jobName.SetFocus
Me.jobNumber.SetFocus
Else
....
End If

End Sub

I want to keep the focus in the jobNumber combo box if <<condition>> 1 is met. The only way I can do this is by setting the focus to another control on the form, and then setting the focus back to jobNumber (as above).

Is there another less klunky way to do this, as just putting in the line Me.jobNumber.SetFocus on its own does not work.

I do not want to add the code to the On Exit event as I have other code in the after update event that must be executed in <<condition 1>> is not met.

Any suggestions gratefully recieved

Gavin
 
Why not use the Before Update event and Cancel?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top