G
Guest
I have a continuous form (with no subforms). If a user enters an invalid
length for the Account # in the [txtAcct#] field, I want a message box to pop
up and tell them what is wrong. I then want it to put the cursor in that
field so they have to fix it before going on.
My code pops up the message box when an invalid length in that field. But
once the user hits OKAY to the msgbox, they are placed in the next field
over. I don't want that. I want them to have to fix the length issue in the
field with the problem. I have tried SetFocus, but I must be doing something
wrong since it goes to the next field over in that record. Anyone see what
is wrong???
Private Sub txtAcct__AfterUpdate()
If Len(Me.[txtAcct#].Text) < 6 Or Len(Me.[txtAcct#].Text) > 7 Then
MsgBox "At least 6 and no more than 7 characters"
Me![txtAcct#].SetFocus
End If
End Sub
length for the Account # in the [txtAcct#] field, I want a message box to pop
up and tell them what is wrong. I then want it to put the cursor in that
field so they have to fix it before going on.
My code pops up the message box when an invalid length in that field. But
once the user hits OKAY to the msgbox, they are placed in the next field
over. I don't want that. I want them to have to fix the length issue in the
field with the problem. I have tried SetFocus, but I must be doing something
wrong since it goes to the next field over in that record. Anyone see what
is wrong???
Private Sub txtAcct__AfterUpdate()
If Len(Me.[txtAcct#].Text) < 6 Or Len(Me.[txtAcct#].Text) > 7 Then
MsgBox "At least 6 and no more than 7 characters"
Me![txtAcct#].SetFocus
End If
End Sub