I've been staring at code and scouring forums for 4 hours in an attempt to figure out why my code isn't working. What I'm basically trying to do is to validate per keystroke what a user enters into a textbox. When the user enters an invalid character, they get an error message. That much works just fine.
When the user clicks "OK" to dismiss the warning, I want the cursor to go back into the textbox and blink at the end of whatever is in there (if anything)
the code I have is as follows:
Private Sub txtAmount_Change()
If Not IsNumeric(txtAmount) Then
If Not txtAmount = vbNullString Then
If Not txtAmount = "$" Then
If Not txtAmount = "." Then
UselessVar = Msgbox("Please enter only valid numbers & symbols ($ .) in the Amount field", vbCritical, "Invalid data entered")
'txtAmount = Left(txtAmount, Len(txtAmount) - 1)
Me.txtAmount.SetFocus
End If
End If
End If
End If
End Sub
The nested if statements check for numbers, then $ then . and if whatever is typed doesn't match those criteria, then they get the error. Right now, I dismiss the error and have to click back into the textbox (txtAmount). How do I get that cursor to blink at the end of the textbox field? This is on a Userform, btw. HEEEELLLPPP!!!!
Thanks in advance!!
Bookmarks