checking a date entered

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

Does anyone know how to write code that will check the date entered against
the current date and display a message saying that the date can not be in the
future?
 
fascal said:
Does anyone know how to write code that will check the date entered against
the current date and display a message saying that the date can not be in the
future?


Use the either the form's or the date control's BeforeUpdate
event:

If Me.datetextbox > Date Then
MsgBox "Future dates not allowed"
Cancel = True
End If
 
I think I replied few days ago:

I would use textbox BeforeUpdate Event:

if me.MyTexbox > date+1 then
msgbox "Wrong date!"
cancel=true
end if
 
WHERE?

In form, you can use a control's validation rule property and validation
text (however, this only applies when something is entered or changed on the
control)

Validation Rule: <=Date() or Is Null
Validation Text: Date must be on or before today
Drop the "or is null" if you won't accept blanks.

In a table (basically the same thing on the field's properties)

In a query? That uses the table's rule and text
 
Thank you! It worked as I expected.

Marshall Barton said:
Use the either the form's or the date control's BeforeUpdate
event:

If Me.datetextbox > Date Then
MsgBox "Future dates not allowed"
Cancel = True
End If
 
I used the following on the Before Update of the date field

Use the either the form's or the date control's BeforeUpdate
event:

If Me.datetextbox > Date Then
MsgBox "Future dates not allowed"
Cancel = True
End If
 
Back
Top