Date Field

  • Thread starter Thread starter Pam
  • Start date Start date
P

Pam

I have a field on my form that's a date field.
I want to place some code (or whatever needs to be done)
in that field if the user enters a date that has not
occured yet, the user is prompted with a message.

ANY help would be greatly appreciated
 
Put this code on the BeforeUpdate event of the text box:

Private Sub txtBoxName_BeforeUpdate(Cancel As Integer)
If Me.txtBoxName.Value > Date() Then
MsgBox "You can't enter a date later than today."
Cancel = True
End If
End Sub

Alternatively, you could put this in the validation property of the textbox:
<= Date()
 
Have you tried to put a test in the lost focus event?
Test the entered date aginst the current date. If it's
greater than the current date then display a message to
the user and clear out the field on the form and have them
re-enter it.
 
Back
Top