I have the following code that is working for my ItemA and ItemB fields but not for my TimePur field.
The ItemA and ItemB are numbers formatted: 0000 (4 numbers exactly in length)
TimePur is Short Time format: 00:00;0
The text boxes are bound to a single table. The formatting declarations are in both the table and in the respective property boxes.
When I enter the wrong value in the ItemA or ItemB textbox, the appropriate error message shows up.
When I enter the wrong time, the system's default error message displays. The ActiveControl.Name in the debug window does NOT display which tells me that the condition is not even being met. So my question is this: is the input mask violation error message for a time field something different than 2279? If so, how do I go about determining what it is?
Access 2010
Code:
Private Sub Form_Error(DataErr As Integer, Response As Integer)
Const INPUTMASK_VIOLATION = 2279
Dim Msg As String
If DataErr = INPUTMASK_VIOLATION Then
Debug.Print Screen.ActiveControl.Name
Select Case Screen.ActiveControl.Name
Case "TimePur"
Beep
MsgBox "The time you entered is invalid!"
Case "ItemA", "ItemB"
Beep
MsgBox "The Item value you entered is invalid!"
Screen.ActiveControl.Value = ""
Case Else
Beep
Msg = "An input mask violation occurred in control "
MsgBox Msg & Screen.ActiveControl.Name & "!"
End Select
Response = acDataErrContinue
End If
End Sub
Many thanks