Gustav Brock
Gustav at cactus.dk
Wed Jun 21 05:50:23 CDT 2006
Hi Dan
Some years ago I posted a general method for situations like yours.
Apply a format string to the textbox and this code:
Private Sub txtDate_BeforeUpdate(Cancel As Integer)
' Catch invalid date entry.
With Me!txtDate
Cancel = Val(.Text) <> Val(Format(.Text, .Format))
If Cancel = True Then
DoCmd.Beep
.Undo
End If
End With
End Sub
/gustav
>>> dwaters at usinternet.com 21-06-2006 04:35 >>>
I was testing a new module and quickly typed '6a' into a date field,
expecting to get an error, but no, the table thinks it's a real date! Turns
out this will enter 6:00:00 AM 12/30/1899. Of course my customers need this
'quick entry feature'!
How can I code to trap this in my form and null the field?
Thanks!
Dan Waters
ProMation <http://www.promationsystems.com/> Systems, Inc.