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!

Progamming dynamic error messages for input mask violations.

Status
Not open for further replies.

rasticle

Programmer
Sep 25, 2006
42
US
I have a problem, I am making a form to enter dates. If I don't put in validation rules eventually the bad dates get into the database and to avoid that I am trying to create an error message that a user will understand. I have the code working for the default inputmask violation, but in the text of the error message I would like to have the name of the control that the error was made. I assume I have to make a string variable. This is what I have so far.. any help would be awesome. Thanks!

Private Sub Form_Error(DataErr As Integer, Response As Integer)
Dim txtBox As String
Const INPUTMASK_VIOLATION = 2279

txtBox = Me.????
If DataErr = INPUTMASK_VIOLATION Then
MsgBox "<variable> needs to be in mm/dd/yyyy format"
Response = acDataErrContinue
End If
End Sub
 
Try either this:
MsgBox Screen.ActiveControl.Name & " needs to be in mm/dd/yyyy format"
Or this:
MsgBox Screen.PreviousControl.Name & " needs to be in mm/dd/yyyy format"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top