DateDiff always tests positive ??

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

Guest

I am trying to test between two dates using:

If 2 > DateDiff("d", DueDate, OpenedDate) Then
MsgBox "The due date .......

but it always tests positive no matter what the dates are. Can anyone tell
me what I am doing wrong?

Thank you, Terri
 
How have DueDate and OpenedDate been declared, and how are they getting
their values?
 
They are text boxes on my form both being a medium date that pick up the
current date as a default with the ability to be modified.
 
If they're text boxes, try:

If 2 > DateDiff("d", Me.DueDate, MeOpenedDate) Then

If that doesn't work, try

If 2 > DateDiff("d", CDate(Me.DueDate), CDate(MeOpenedDate)) Then
 
I had tried something similar:

If 2 < DateDiff("d", [Me.DueDate], [Me.OpenedDate]) but recieved an Access
error message not being able to find '|' field in my expression, so I tried
other means. I was able to work with both methods that you suggested and
after some additional testing realized that I was looking for a "-2"
comparison also.

Thank you very much for your help!
 
If 2 < DateDiff("d", [Me.DueDate], [Me.OpenedDate]) but recieved an Access
error message not being able to find '|' field in my expression

That's because of misplaced brackets. It's looking for controls NAMED
Me.DueDate and Me.OpenedDate (rather than controls named DueDate and
OpenedDate), since you put the Me. inside the square brackets. Use
Me.[DueDate] instead and this particular problem will go away.

John W. Vinson[MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top