Link to home
Start Free TrialLog in
Avatar of SteveL13
SteveL13Flag for United States of America

asked on

Make field on a form manitory and return user to that field before anything else can be entered if they skip it

I have a form with a combo-box.  That field is tab 0 on the form so the focus is on it when the form opens.  But if the user skips over the field and attempts to enter any other data in any other field before the combo-box has had a record selected I want the data they entered in any other field deleted, have a message box appear letting the user know they have to select a record in the combo-box before proceeding, and return the focus to the combo-box.

How do this?
Avatar of SteveL13
SteveL13
Flag of United States of America image

ASKER

So I have this code in the lostfocus event of the combobox field but it is not taking the user back to the combobox field.  Instead it is setting the focus on the next field.  ????

Private Sub cboSalesperson_LostFocus()

    If IsNull(Me.cboSalesperson) Then
        MsgBox "You must select a salesperson before proceeding!"
        Me.cboSalesperson.SetFocus
        Exit Sub
    End If

End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of PatHartman
PatHartman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It is the latter and I'll use the BeforeUpdate event.  Thanks.
The Form's BeforeUpdate event is without question, the most important and useful event when it comes to keeping your data accurate.
Thanks again.  Is much appreciated.