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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Where’s the event?

Status
Not open for further replies.

LouiseJ

Technical User
May 18, 2005
29
GB
I have a Form with an unbound control txtABC, cmdOK and cmdCancel.

txtABC has an Input Mask and cmdCancel closes the form, acSaveNo.

Situation is that a user starts to enter data into txtABC and then decides to cancel (cmdCancel) with out completing the required Input Mask string – Result: The form will not close and an information message is displayed, ‘The value you entered isn’t appropriate for the input mask ‘Blah Blah’ specified for this field’.

I have tried various ways around this including setting the Input Mask property of txtABC OnEnter and resetting it OnExit. However I cannot find the event before the message is displayed.

Where is the event if there is one? If there is no event before this message how can I trap the message? I have not been able to get OnError to trap this either.

Any Ideas?

Thanks

LouiseJ
 
You need Form_Error:

Code:
Private Sub Form_Error (DataErr As Integer, Response As Integer)
      Const INPUTMASK_VIOLATION = 2279
      If DataErr = INPUTMASK_VIOLATION Then
         MsgBox "There was an input mask violation!"
         Response = acDataErrContinue
      End If
End Sub
 
It's the 'On Error' event for the form. One thing the user can do outside of a programatic answer is to hit the 'escape' key to clear the partially-entered data.
Or you can clear the entry from within the 'on error' event if that's what you want.

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
Thank you Remou & traingamer

You have saved me again!

LouiseJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top