setfocus

G

Guest

Hi....I have a control that is numeric (integer). I want to make sure user
enters only 6 digit number not more or less. If they enter less then the
system should display a message and setfocus back to that field. I wrote the
code below and it works but it doesn't set the focus to the field. It goes
back to the next field in tab index.

Private Sub tblClient_CID_AfterUpdate()


If Len(Me.tblClient_CID) <> 6 Then
MsgBox "Invalid CID. Please Reenter.", vbCritical, "AE Client
Relationship Management"
Me!tblClient_CID.SetFocus

End If

End Sub
 
A

Allen Browne

Drop the code.

Set a Validation Rule on the text box of:
Between 100000 And 999999

(Note that leading zeros are meaningless in a Number type field.)
 
G

Guest

Allen - Thanks for the suggestion. However, I want a customized message to be
displayed rather than system validation message. Any way to do that with
validation rule.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top