Leave cursor on current form field

Cameo

Registered User.
Local time
Today, 13:01
Joined
Aug 5, 2009
Messages
34
I feel so stupid...like I should know this. But... I have an After Update event, whereby when the user inputs a value into a text field and then tabs over, the code checks for the value's validity. If invalid, I issue a msg to the user stating such. BUT, the cursor moves to the next field anyway. How do I get the cursor to stay on that field?
Thanks.
 
Hello....

You will need to add....

Me.[FieldName].SetFocus
 
You should use the fields before update event and cancel the event if it does not meet your criteria.
 
Both these still allow the cursor to move to the next field after I issue the popup saying this is an incorrect value.
 
Both these still allow the cursor to move to the next field after I issue the popup saying this is an incorrect value.

Not if you correctly cancel the event.
 
OK...how do I correctly Cancel the event?
 
OK...how do I correctly Cancel the event?

Code:
Private Sub YourTextBox_BeforeUpdate(Cancel As Integer)

    If IsNull(YourTextBox) Then
    
        Cancel = True
        MsgBox "null"
    
    End If

End Sub
 
I was "Dazed and Confused", but now I've been shown the light. Thank you ghudson!
 

Users who are viewing this thread

Back
Top Bottom