I have an AfterUpdate event to verify the account number entered is the correct number of digits. It includes a Do... Loop that is not functioning. When I debug, I get "Loop without Do". It worked fine until I changed the text of the prompt for a valid number. I changed it back and it's didn't fix the issue. Can you tell me what's wrong with the code? I'm pretty new to VBA, so be kind.
Code:
Private Sub ACDVPrsnID_AfterUpdate()
Do
'---validate accnt number is 10 digits---
If Len(ACDVPrsnID) = 10 Then
ACDVPrsnID = Format(ACDVPrsnID, "@@ @@@@ @@@@")
ElseIf Len(ACDVPrsnID) = 12 Then
ACDVPrsnID = Format(ACDVPrsnID, "@@@@@@@@@@@@")
Else
Me.ACDVPrsnID = Null
'---Prompt for valid account number---
Dim Message, Title, Default, MyValue
Message = "*** ERROR: " & ACDVPrsnID & " is not a valid Account Number. Enter a valid account number." ' Set prompt.
Title = "Account Number Error" ' Set title.
ACDVPrsnID = InputBox(Message, Title, Default)
If MyValue = vbCancel Then
GoTo Exit_ACDVPrsnID_AfterUpdate
'---end prompt---
End If
Exit_ACDVPrsnID_AfterUpdate:
Exit Sub
Loop Until Len(ACDVPrsnID) = 10 Or Len(ACDVPrsnID) = 12
End Sub