[AccessD] Expiration Date

Hollis, Virginia hollisvj at pgdp.usec.com
Tue Oct 27 09:09:52 CDT 2009


I am trying to show the items that will expire in the next 30 days. If
it has already expired I need to show that the item has expired.

 

The below code I tried having a calculated field (txtExpireDays) that
calculates the DateDiff to determine the number of days between the
Early Expiration date & today's date.

 

If the item is going to expire it shows a message that "Some items will
expire in "number of" days." If the item's expiration date has passed
(it is expired) then the DateEarlyExp field is red & it's label shows -
"Expired".

 

I placed this in the OnCurrent.  The problem is (I think) if you hit a
record with a Null DateEarlyExp it keeps the previous records
calculations & shows that on the screen as you scroll through the
records.

 

Should the DateDiff calculation be somewhere in the with the code
OnCurrent instead of a separate text box? Did I write this completely
wrong (a better way to do this)?

 

 

Text box on the form (hidden)    'DateEarlyExp.value =
DateDiff('d',Date(),[DateEarlyExp])

 

If (txtExpireDays > 0 And txtExpireDays <= 31) Then

    Me.lblExpire.Visible = True

    Me.lblExpire.ForeColor = lngRed

    lblExpire.Caption = "Some items will expire in " & txtExpireDays & "
days"     

ElseIf txtExpireDays < 1 Then

    Me.DateEarlyExp.ForeColor = lngRed

    EarlyExpLabel.ForeColor = lngRed

    EarlyExpLabel.Caption = "Item Expired:"

Else

    lblExpire.Visible = False

    EarlyExpLabel.Caption = "Early expiration:"

    EarlyExpLabel.ForeColor = 8388608

    Me.DateEarlyExp.ForeColor = lngBlack

End If




More information about the AccessD mailing list