Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: DateDiff always tests positive ??

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

DateDiff always tests positive ??
Terri 29.09.2006 15:23:02
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
Re: DateDiff always tests positive ??
"Douglas J. Steele" <NOSPAM_djsteele[ at ]NOSPAM_canada.com> 29.09.2006 15:32:05
How have DueDate and OpenedDate been declared, and how are they getting
their values?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Terri" <starpegasus[ at ]discussions.microsoft.com> wrote in message
news:B15669D6-8F72-4D1F-A0DB-871A32B80DD2[ at ]microsoft.com...
[Quoted Text]
>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


Re: DateDiff always tests positive ??
Terri 29.09.2006 18:32:02
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.

"Douglas J. Steele" wrote:

[Quoted Text]
> How have DueDate and OpenedDate been declared, and how are they getting
> their values?
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)
>
>
> "Terri" <starpegasus[ at ]discussions.microsoft.com> wrote in message
> news:B15669D6-8F72-4D1F-A0DB-871A32B80DD2[ at ]microsoft.com...
> >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
>
>
>
Re: DateDiff always tests positive ??
"Douglas J. Steele" <NOSPAM_djsteele[ at ]NOSPAM_canada.com> 29.09.2006 18:35:08
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

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Terri" <starpegasus[ at ]discussions.microsoft.com> wrote in message
news:214EF587-A3F1-478A-BB27-26A9A4B2A62A[ at ]microsoft.com...
[Quoted Text]
> 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.
>
> "Douglas J. Steele" wrote:
>
>> How have DueDate and OpenedDate been declared, and how are they getting
>> their values?
>>
>> --
>> Doug Steele, Microsoft Access MVP
>> http://I.Am/DougSteele
>> (no e-mails, please!)
>>
>>
>> "Terri" <starpegasus[ at ]discussions.microsoft.com> wrote in message
>> news:B15669D6-8F72-4D1F-A0DB-871A32B80DD2[ at ]microsoft.com...
>> >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
>>
>>
>>


Re: DateDiff always tests positive ??
Terri 29.09.2006 19:13:01
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!

"Douglas J. Steele" wrote:

[Quoted Text]
> 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
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)
>
>
> "Terri" <starpegasus[ at ]discussions.microsoft.com> wrote in message
> news:214EF587-A3F1-478A-BB27-26A9A4B2A62A[ at ]microsoft.com...
> > 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.
> >
> > "Douglas J. Steele" wrote:
> >
> >> How have DueDate and OpenedDate been declared, and how are they getting
> >> their values?
> >>
> >> --
> >> Doug Steele, Microsoft Access MVP
> >> http://I.Am/DougSteele
> >> (no e-mails, please!)
> >>
> >>
> >> "Terri" <starpegasus[ at ]discussions.microsoft.com> wrote in message
> >> news:B15669D6-8F72-4D1F-A0DB-871A32B80DD2[ at ]microsoft.com...
> >> >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
> >>
> >>
> >>
>
>
>
Re: DateDiff always tests positive ??
John Vinson <jvinson[ at ]STOP_SPAM.WysardOfInfo.com> 29.09.2006 23:17:19
On Fri, 29 Sep 2006 12:13:01 -0700, Terri
<starpegasus[ at ]discussions.microsoft.com> wrote:

[Quoted Text]
>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]

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net