For the first one, the validation error only works if you put a validation text in. They go together.
For the second, if you put it on the ON ERROR event, then ANY error happening in ANY procedure will default to that event. However, if you want SPECIFIC errors for EACH event (e.g. ON CURRENT, ON OPEN, NameOfControl_AFTERUPDATE, etc.) then you don't put it there. You place it in the specific event itself. For example, suppose you have textbox AfterUpdate event. It'd look something like this:
Private Sub MyTextBox_AfterUpdate()
On Error GoTo Err_MyTextBox_AfterUpdate
'Your code here.
Exit_MyTextBox_AfterUpdate:
Exit Sub
Err_MyTextBox_AfterUpdate:
If Err.Number = xxxx Then
MsgBox "Custom Error Message Here", vbCritical, "Error " & Err.Number
Else
MsgBox Err.Description, vbCritical, "Error " & Err.Number
End If
Resume Exit_MyTextBox_AfterUpdate
End Sub
Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
|