Comparing two dates

T

Todd

I am trying to compare a date that the user will enter with a set date in the
system. In this instance, it will be the last day of the school year. If the
day they entered is greater than the last day of the school year, I want a
pop up box to appear indicating they have entered a invalid date. I can not
seem to get the code to work. The "Date_Return" is a field int eh table that
is set as Date/Time. Below is an example of what I used:

Dim StrWhere As String

StrWhere = "05/25/2007"

If Date_Return > StrWhere Then
MsgBox "The Date has exceeded the current school year. Please make
the necessary changes."
End If

Thank you for any help.
 
T

Todd

I was unaware of that.
So all I would need is

IF Date_Return > 05252007 Then
.....


Would that work?
 
D

Douglas J. Steele

No, you'd need

If Date_Return > #05/25/2007# Then

Of course, if Date_Return is a field in the table, how are you reading that
table? You need to open a recordset, and use

If RecordsetName.Date_Return > #05/25/2007# Then
 
Top