David McAfee
davidmcafee at gmail.com
Tue Oct 27 13:11:04 CDT 2009
Is this on a continuous form?
On Tue, Oct 27, 2009 at 10:57 AM, Hollis, Virginia
<hollisvj at pgdp.usec.com> wrote:
> Still doesn't work correctly. If I hit a record that is Expired all the
> other records show Expired even if they aren't.
>
> Would it work better if I used a Select Case? Would that have something
> to do with it?
>
> **************
>
> I'd keep it in the OnCurrent event.
>
> Use NZ() and some future date
>
> 'DateEarlyExp.value =
> DateDiff('d',Date(),NZ([DateEarlyExp],DATE()+365))
>
> ***************
> On Tue, Oct 27, 2009 at 7:09 AM, Hollis, Virginia
> hollisvj at pgdp.usec.com
> <http://databaseadvisors.com/mailman/listinfo/accessd> > wrote:
> 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
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>