It is probably around the =True section of your If statement.
When I run into these problems I do something like this on the OnCurrent Event
MsgBox Me.dtmWarrantyExpiry
MsgBox Me.ysnWarranty
MsgBox MyDate
This will tell you exactly what Access sees as a value and you can adjust
your statement to reflect the correct values (if they are not already
correct).
Try that and write back.
PJ
Hi PJ
OK, so now my code is:
Private Sub Form_Current()
Dim MyDate
MyDate = Date
MsgBox Me.dtmWarrantyExpiry
MsgBox Me.ysnWarranty
MsgBox MyDate
If (Me.dtmWarrantyExpiry < MyDate) And (Me.ysnWarranty = -1) Then
Me.ysnWarranty = 0
MsgBox "Warranty has expired for this item", vbOKOnly, "TOG Systems"
Me.SKU_Number.SetFocus
End If
End Sub
The values in the message boxes are what I expect to see:
Warranty Expiry: May 29 2007
Warranty -1
My Date: May 30 2008
So, the warranty expired last year, the warranty check box needs to change
to 0 and the message box needs to show up.

Signature
CJ
> It is probably around the =True section of your If statement.
>
[quoted text clipped - 35 lines]
>>
>> Any ideas?
CJ - 30 May 2008 19:27 GMT
Fixed it!
dtmWarrantyExpiry is a calculated field that returns a date. It's one of
those instances where you need to perform the calculation in order for the
comparison to work. So, my code is:
Dim MyDate
MyDate = Date
If (Me.Date_Purchased + Me.sngWarrantyDuration) And (Me.ysnWarranty = -1)
Then
Me.ysnWarranty = 0
MsgBox "Warranty has expired for this item", vbOKOnly, "TOG Systems"
Me.SKU_Number.SetFocus
End If
Thanks for steering me in the right direction!
CJ
---------------------------------------------------------
Know thyself, know thy limits....know thy newsgroups!
> Hi PJ
>
[quoted text clipped - 66 lines]
>>>
>>> Any ideas?
CJ - 30 May 2008 19:49 GMT
Sorry, there was an error in the code I posted.
It should have been :
Dim MyDate
MyDate = Date
If (Me.Date_Purchased + Me.sngWarrantyDuration) < MyDate And (Me.ysnWarranty
= -1) Then
Me.ysnWarranty = 0
MsgBox "Warranty has expired for this item", vbOKOnly, "TOG Systems"
Me.SKU_Number.SetFocus
End If
CJ
> Fixed it!
>
[quoted text clipped - 91 lines]
>>>>
>>>> Any ideas?

Signature
Thanks for taking the time!
CJ
---------------------------------------------------------
Know thyself, know thy limits....know thy newsgroups!