View Single Post
 
Old 12-10-2022, 05:43 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

I don't think AfterUpdate is the right trigger. Try using the trigger of leaving the text box instead.
Code:
Private Sub ObjectCode_Exit(ByVal Cancel As MSForms.ReturnBoolean)
  Dim sVals As String, sEntry As String
  sVals = "6119,6121,6129,6139,6141,6142,6413,6145,6146,6148,6149,6223,6237,6238,6239,6249,6256,6259,6267,6268,6269,6291,6293,6294,6299,6329,6339,6395,6399,6410,6411,6497,6499"
  sEntry = Me.ObjectCode.Value
  If Len(sEntry) <> 4 Or Not sVals Like "*" & sEntry & "*" Then
    MsgBox "Not a valid Object Code. Please verify and try again", vbOKOnly, "Invalid Input"
    Me.ObjectCode.Value = Null
    Cancel = True
  End If
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote