Hi folks.
I have a query, qryHistory, which has the following field:
DaysOverdue: IIf([Due]<Date(),DateDiff("d",[Due],Nz([Return],Date())),0)
I also have a form (continuos), frmHistory, which is based on
qryHistory.
frmHistory has a checkbox, chkReturn, which has the following code
below. chkReturn assigns the current date to Return and calculates
Fine based on DaysOverdue and a few other criteria's. When chkReturn
is clicked again, the changes will be undone.
------------------------------------------------------------------------------
Private Sub chkReturn_Click()
Static X
X = X + 1
If X > 2 Then X = 1
Select Case X:
Case 1: Me.Return = Date
If Me.DaysOverdue > 0 Then
If (Me.MemType = "Staff") Or (Me.MemType = "Lecturers")
Then
Me.Fine = Me.DaysOverdue
End If
If (Me.MemType = "Student(PT)") Or (Me.MemType =
"Student(FT)")Then
If Me.DaysOverdue > 7 Then
Me.Fine = (7 * 0.5) + (Me.DaysOverdue - 7)
Else
Me.Fine = Me.DaysOverdue * 0.5
End If
End If
End If
Case 2: Me.Return = Null
Me.Fine = Null
End Select
End Sub
------------------------------------------------------------------------------
I originally wanted DaysOverdue and Fine to be calculated when the
form is opened; however, assigning the calculations to the form's
OnOpen event failed (partly because of the fact that it is continuos,
I suspect). Someone in the forum suggested that I assign the coding of
DayOverdue to the query, which I did, and it worked (thank you!!!).
Which then leaves Fine, which I assigned to a checkbox, which works.
But I also want the form to calculate Fine when the form is opened.
Any ideas?
FrmHistory also has another checkbox, chkRenew. This is it's coding:
------------------------------------------------------------------------------
Private Sub Renew_Click()
Static X
X = X + 1
If X > 2 Then X = 1
Select Case X:
Case 1: Me.Borrow = Date
Me.Due = Date + 7
Me.Return = Null
Case 2: Me.Undo
End Select
End Sub
------------------------------------------------------------------------------
If I click on chkRenew, the values of Borrow and Due will be changed
as per the coding above, and if I click on chkRenew again, the changes
will be undone. However, if I click on chkRenew the 1st time, then
sort the form (or edit it in any way), then click on that specific
chkRenew the 2nd time, the values of Borrow and Due will not be
changed back to its original value. How do I correct this?