Error Handling vs Error Code 2113

R

RichW

My company issues alpha-numeric employee numbers; for instance, B12345678.

In a form I have created a text field that permits users to input their
employee number, but I wish to prevent them from including the preceding
letter; for instance, employee number B12345678 could only be inputted as
12345678.

As a text field, the field already prevents the user from inputting letters
by having error code 2113 pop into view. The actual error message reads,
"The value you entered isn’t valid for this field.@For example, you may have
entered text in a numeric field or a number that is larger than the FieldSize
setting permits."

I wish to change the above error message to read "Please omit preceding
letter from BEMS ID". I tried the following language, but without luck:

*********************************************
Private Sub txtBEMSID_Click()

On Error GoTo Err_txtBEMSID_Click

Err_txtBEMSID_Click:

MsgBox Err.Description
MsgBox Err.Number

If Err.Number = 2113 Then
MsgBox ("Please omit preceding letter from BEMS ID")

End If

Resume Exit_txtBEMSID_Click

End Sub
*********************************************

Because there are many other text fields in the form, using error handling
for 2113 at form level is not successful for it will result in the same error
message (Please omit preceding letter from BEMS ID) for any text field that
results in error code 2113.

Any ideas?

Thanks in advance,
Rich
 
E

Elson Markwick

You could use an input mask on the text control - that will silently prevent
users from putting in a letter.
You could also use a validation rule and validation text on the text control.

Cheers, Elson
 
R

RichW

Elson,

Thank you for your reply and suggestions.

Because this is my first project with Access, I have a lot to learn.

Could you please provide be an example of what you are suggesting, or point
me in the right direction so that I may learn more of what you are suggesting?

Thanks in advance,
Rich
 

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

Top