Comparing Dates in VBA

Yarimel

Registered User.
Local time
Today, 08:18
Joined
Aug 13, 2008
Messages
10
I need to develop a function to compare a date with the current date and to print the message indicated. I cannot get the code below to work proprerly. If enter a future date, I still get the "expired, need to file a new char" message, please help!!!

Public Sub CharIsExpired(ByVal Value As Date)

dtExpirationDate = Value
dtCurDate = Now()

If dtExpirationDate < dtCurDate Then
Debug.Print "Expired, Need To File a New Char"
Debug.Print dtCurDate
Else
Debug.Print "Current"
Debug.Print dtCurDate
End If


End Sub
 
I see no Dim declarations for dtExpirationDate or dtCurDate. What are their respective variable types?
 
Why not just
If Value < Date Then

No point in using Now as you are not interested in time.

Brian
 
Both dtExpirationDate and dtCurDate are of type date.
 
I would also do a debug.print on the Value that is coming in. Before it is assigned. Make sure it is a valid date format.
 

Users who are viewing this thread

Back
Top Bottom