Access 2007 SqlServer 2008 using MZTools
The development I am working on has lots of date fields. I am trying to develop a consistent process for the error handler when dates are entered. This is my first time trying to work on Error Handlers. When a person enters a date and mucks it up such as YYYY-M-DD the error handler fires and when it is finished I want it to clean up the date field on the form by clearing the offending data and placing the cursor at the start of the field. Here is my code. No matter what I do I cant get the code after the error message to work.I don't understand where the clean up code should go. Once I get this down I will apply it to all the date controls. Some of the error handling samples I have seen are really complex and long.
Input Mask: 0000\-99\-99;;_
Validation Rule: Is Null Or Not ALike "%[!0-9]%" And Len([AOBORFAsentDT])=8
Validation Text: Date must be eight digits and entered YYYY-MM-DD.
Control Tip Text: Enter Dates as YYYY-MM-DD
Code:
Private Sub AOBORFAsentDT_Click()
On Error GoTo AOBORFAsentDT_Click_Error
Me.AOBORFAsentDT.SelStart = 0
On Error GoTo 0
Exit Sub
AOBORFAsentDT_Click_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure AOBORFAsentDT_Click of VBA Document Form_FrmPropYrFile"
Resume AOBORFAsentDT_Click_Error
Me.AOBORFAsentDT SetFocus
Me.AOBORFAsentDT = Nothing
Me.AOBORFAsentDT.SelStart = 0
End Sub
Thanks Phred