Date Field

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
 
K

Ken Snell

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()
 
P

Peter Nunez

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top