How to check if a date is = to another date

P

pokdbz

I have this statement in my code. The first part of the IF statement is
giving me the problem. If ManiaCheck is = 12/12/1900 it is not going to the
true part of the statement it is going to the else part. Any ideas of what I
am doing wrong?

If (ManiaCheck = (12 / 12 / 1900)) Or ((ManiaCheck + 180) >= DATE) Then

stDocName = "Mania"
DoCmd.OpenForm stDocName, , , , , , Me!SSN.Value
Else
 
D

Dirk Goldgar

pokdbz said:
I have this statement in my code. The first part of the IF statement
is giving me the problem. If ManiaCheck is = 12/12/1900 it is not
going to the true part of the statement it is going to the else part.
Any ideas of what I am doing wrong?

If (ManiaCheck = (12 / 12 / 1900)) Or ((ManiaCheck + 180) >= DATE)
Then

stDocName = "Mania"
DoCmd.OpenForm stDocName, , , , , , Me!SSN.Value
Else

Access doesn't recognize this -- 12 / 12 / 1900 -- as a date literal.
Instead, it thinks you want to calculate 12 divided by 12 divided by
1900. Date literals should be enclosed in the # character:

If (ManiaCheck = #12/12/1900#) _
Or ((ManiaCheck + 180) >= Date) _
Then
 
O

Ofer

You can try this

If (format(ManiaCheck,"dd/mm/yyyy") = "12/12/1900") Or ((ManiaCheck + 180)
 
Top