Comparing Dates in VBA

trigirl67

Registered User.
Local time
Today, 07:42
Joined
Dec 10, 2011
Messages
10
If I want to say...If the [Completion Date] > 6 months old, then do something...how do you say in VBA code?
 
Presuming it's on the form, along these lines:

If Me.CompletionDate < DateAdd("m", -6, Date()) Then
 
Thank you but what if the completion date comes from a table not a field on the form?
 
You could use DLookup() or open a recordset to get the value from the table. Perhaps you can clarify what you're trying to achieve.
 
How do you do an open recordset? There is a form which is linked to a table and in the table there is a field called completion date that is updated from a different form. So I want to update a field [Request Type] based on an ID field and if the completion date is > 6 months old, then update the requet type field to "New".
 
So how would you incorporate the Dlookup and the if statement?
 
If DLookup(...) < DateAdd("m", -6, Date()) Then
 

Users who are viewing this thread

Back
Top Bottom