Hello, I have 2 issues that I need assistance with. First, I want to have the text box clear out if the incorrect info is input to it. I have tried Me.Location = "" and Me.Location = Null after the message box, neither of which seem to work.
I also have the below code and need it to stop when the first set of code gives the error message. right now, if the user enters anything in the Location text box, the first code will run, then it automatically runs the second code where it beeps and goes to the next record. I want it to stop if the incorrect data is input and only run the second code when the data is correct. Can anyone provide assistance?
I also have the below code and need it to stop when the first set of code gives the error message. right now, if the user enters anything in the Location text box, the first code will run, then it automatically runs the second code where it beeps and goes to the next record. I want it to stop if the incorrect data is input and only run the second code when the data is correct. Can anyone provide assistance?
Code:
Private Sub Location_BeforeUpdate(Cancel As Integer)
If Not Me.Location Like "[Z]*" Then
Me.Location = Null
Cancel = True
Beep
MsgBox "Entered data is not a Location."
End Sub
Private Sub txtLocation_Exit(Cancel As Integer)
Dim X As Long
For X = 1 To 3
Beep
Sleep 1000
Next
End Sub