Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Input Masks - Error Messages for Them

Status
Not open for further replies.

ChemistZ

Programmer
Oct 30, 2001
70
US
I give up I think on trapping the error message that comes up with an incorrect entry for an input mask. However, I decided to try not setting the imput mask property in the properties box but to use an If statement in code to check for it. For instance, I have a field called Cashier_No and I want the input mask to be 00009 so that the first 4 entries are required and must be numerical and the last entry is optional but must also be numerical. So, in code I say
if cashier_no.inputmask<>00009 then
msgbox &quot;blah blah blah&quot;
cashier_no.setfocus

However, I can not seem to get a good event to put this code into. I tried OnExit, OnBeforeUpdate, OnAfterUpdate, OnLostFocus and it gives the message but ignores the setfocus statement which allows the user to bypass the field anyway - any suggestions???
 
I used this to trap a date error:

Private Sub Form_Error(DataErr As Integer, Response As Integer)

' Traps date error
If DataErr = 2279 Then

' Does not display message box
Response = 0
MsgBox &quot;Please enter complete date&quot;, vbExclamation

End If

End Sub
Linda Adams
Visit my web site for writing and Microsoft Word tips:
 
What is a &quot;DataErr&quot; and how did you know you could use it? I looked up a list of Trappable errors and didn't see #2279. How did you get that number?
 
I am only replying to get this back at the top today to see if anyone today can help with this situation
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top