I have the code that validates my field (see below), but I also want to delete the date that was entered so that the user has a blank field to start entering a complete date (instead of editing the previous incorrect date). Trying to set the value (e.g. txtDate=Null) is not allowed because the field value has not been committed yet.
txtDate.Undo seems to bypass the entire validation and actually commits the incorrect value. Is there any way to clear the field to start again?
-------------------
Rob Foye
Database Management
Regions Bank
txtDate.Undo seems to bypass the entire validation and actually commits the incorrect value. Is there any way to clear the field to start again?
Code:
Private Sub txtDate_BeforeUpdate(Cancel As Integer)
Dim dtstart As Date
If IsNull(txtDate) Then
Cancel = True
Exit Sub
End If
dtstart = txtDate
If DatePart("W", dtstart, vbMonday) > 5 Or DLookup("holHolidate", "tblHolidays", _
"[holHoliDate]= #" & CStr(dtstart) & "#") Or IsNull(txtDate) Then
MsgBox "The date you entered is not a business day." & _
vbCrLf & "Please enter a new date.", vbOKOnly, "Not a business day"
Cancel = True
End If
-------------------
Rob Foye
Database Management
Regions Bank