Hello,
I have a text box on a form, and I want to save the user input value to a table when the user moves to a different control on the form or closes the form.
I placed my code as a LostFocus event, and it is properly inserting the values. However, I also want to be able to check for a null value and return the focus to textbox (see below).
This will trigger the message, but does not set the cursor/focus back to the textbox I want.
Question:
What is the best way to check for a null value as soon as the user leaves the textbox and place the cursor back in the textbox?
I have a text box on a form, and I want to save the user input value to a table when the user moves to a different control on the form or closes the form.
I placed my code as a LostFocus event, and it is properly inserting the values. However, I also want to be able to check for a null value and return the focus to textbox (see below).
Code:
If Not IsNull(Me.textbox1.Value) Then
strInput = Me.textbox1.Value
strSQL = "INSERT INTO table1 ([field1]) VALUES ('" & strInput & "')"
db.Execute (strSQL)
Else
MsgBox "Please enter a value"
Me.textbox1.SetFocus
Exit Sub
End If
Question:
What is the best way to check for a null value as soon as the user leaves the textbox and place the cursor back in the textbox?
Comment