This a rather old persistent problem I`m facing. I have a form with a text
box bounded to a date field of a table. I have created a BeforeUpdate()
event handler for the text box.
The handler is supposed to check whether a valid date has been entered
before allowing the update of the text box.
When I enter an invalid date though, the handler does not seem to get
called. Instead I get an error message from Access. When a valid date is entered the event handler executes, but finds nothing wrong.
Can somebody shed some light?
The event handler code is shown below :
Private Sub Hmeromhnia_BeforeUpdate(Cancel As Integer)
If Not IsDate(Me.Hmeromhnia) Then
MsgBox "Ic a?iaaeo? cianiici?a", vbCritical
Cancel = True
This is because this is a bounded TextBox to a Date Field, and ACCE$$ has internal check for Date Formats, which takes place before the Before Update event takes place.
If you use an unbounded TextBox, your Before Update event would fire even if you enter an invalid date value
Is there no way to overcome this when using a bounded text box? This causes a lot of problems when an invalid date is input. Access continues to display error messages even if the user decides to close the form.
The only way the form can be exited is for the user to input a valid date.