Thanks Ken, the DIM NDD As Date solved the problem
>-----Original Message-----
>Assuming that you didn't Dim NDD as a date variable,
it's likely a variant
>variable. When you set it equal to the result of a
Format statement, you'll
>get a string.
>
>Thus, you're always testing a string against a date
value in the If
>statement. Because they're not the same data type,
ACCESS will change one to
>match the other, and I'm guessing that it is changing
the result of the
>DateAdd function to a string. As such, the > operator
will test based on
>string comparison, not based on date value comparison.
>
>Change this line
> NDD = Format(Me![NextDueDate], "Short Date")
>
>to this
> NDD = DateValue(Me![NextDueDate])
>
>I also would add
> Dim NDD As Date
>
>to the procedure's code.
>--
>
> Ken Snell
><MS ACCESS MVP>
>
>"JerryC" <(E-Mail Removed)> wrote in
message
>news:550101c5233b$f553a730$(E-Mail Removed)...
>> NDD = Format(Me![NextDueDate], "Short Date")
>> PMRange = 8
>> TD = Format(Date, "Short Date")
>>
>> If NDD > DateAdd("d", PMRange * 2, TD) = True Then
>> MsgBox "Do This"
>> End If
>>
>> Why is If statment always true ???
>>
>> Thanks for your input.
>
>
>.
>
|