Create a query to use as the source for your form.
In query design, type something like this into the field row:
DaysOverdue: CLng(IIf([Due] < Date(), DateDiff("d", [Due], Nz([Return],
Date())), 0))
For more information on creating calculated fields, see:
http://allenbrowne.com/casu-14.html
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users -
http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Aravind" <solaris_nite@hotmail.com> wrote in message
news:6174ca57.0405271958.43184d46@posting.google.c om...[color=blue]
> Hi folks.
>
> I have a form, frmHistory, whose Default View is set to Continuos
> Forms.
> The following is the coding that I inserted in frmHistory's On Open
> event; it is intended to calculate the number of overdue days
> (DaysOverdue [unbound]) for each record. Unfortunately, it only works
> on the 1st record, and all subsequent DaysOverdue value of the
> subsequent records are set to the 1st record's value. If I change or
> delete the 1st record's value, all subsequent records reflect this new
> value. Where did I go wrong? I've checked out other posts, but am
> unable to find a solution. Thanks for your help.
>
> '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''
> Private Sub Form_Open(Cancel As Integer)
> Dim rst As Recordset
> Set rst = CurrentDb.OpenRecordset("history")
>
> rst.MoveFirst
> Do Until rst.EOF
> If (IsNull(Me.Return)) And (Me.Due < Date) Then
> Me.DaysOverdue = DateDiff("d", Me.Due, Date)
> End If
>
> If (IsNull(Me.Return) = False) And (Me.Due < Date) Then
> Me.DaysOverdue = DateDiff("d", Me.Due, Me.Return)
> End If
>
> If Me.DaysOverdue < 0 Then
> Me.DaysOverdue = 0
> End If
>
> rst.MoveNext
> Loop
>
> rst.Close
> Set rst = Nothing
> End Sub
> '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''[/color]