Good morning! I've created a form to add a record to a table with unbound text boxes. The add record event is handled by a DoCmd.RunSQL INSERT statement.
Before running the INSERT command, I would like to make sure that the user has entered something in each text box before moving on to another text box by any means (tab, mouse-click, etc). If they try to move out of a blank text box, throw a warning and then return focus to the blank control.
I have tried most of the pertinent Events for the control (Click, Before Update, After Update, Exit). With any of those event subs, the MsgBox displays but focus does not go back to the blank control - instead, focus stays on the next control in the tab order.
Here is the code for the Exit event:
Private Sub VinNum_Exit(Cancel As Integer)If IsNull(VinNum) Then
MsgBox "VIN # required.", vbExclamation, "Invalid Entry"
VinNum.SetFocus
End If
End Sub
Thoughts?