Set value of check box to return value of function

Kassy

Registered User.
Local time
Today, 13:43
Joined
Jan 25, 2006
Messages
66
I have an unbound check box on a form and I want to set the value of the check box to the return value of the function in the parent fors Current event procedure i.e. the relevant values into the function to 'check the box ' if a fee is due. Exactly what part of the function is the return value?
Function:-
Public Function FeeDue(lngMemberID As Long, _
intDay As Integer, _
intMonth As Integer, _
intYearsMembership) As Boolean

Dim dtmRenewalDate As Date
Dim strCriteria As String

' set default return value to False
FeeDue = False

' get renewal date in current year
dtmRenewalDate = DateSerial(Year(VBA.Date), intMonth, intDay)

' if current date before renewal date subtract one year
If VBA.Date < dtmRenewalDate Then
dtmRenewalDate = DateAdd("yyyy", -1, dtmRenewalDate)
End If

' has member paid fee since renewal date?
strCriteria = "MemberID = " & lngMemberID & " And PaymentDate >= #" & _
Format(dtmRenewalDate, "mm/dd/yyyy") & " #"

If IsNull(DLookup("MemberID", "S_Payments_Table", strCriteria)) Then
' no payment made since renewal date.
' has member been member for <= specified YearsMembership?
' i.e. how many payments have they made to date
strCriteria = "MemberID = " & lngMemberID
If Dcount("*", "S_Payments_Table", strCriteria) <= intYearsMembership Then
FeeDue = True
End If
End If

End Function
 
Last edited:
FeeDue = False
and
FeeDue = True

Are the return values, what ever FeeDue has as value at the end of the execution of the function it returns as value.

Just guessing here, You did not make this function yourselve?
 
Thank you that’s what I thought but the (unbound)check box is greyed out. I wish I had made the function but I didn’t .I thought I understood it until I couldn’t get it to work which made me think I wasn’t putting in the correct values. If I check the box on a members payment as expired then all following records remain the same.
I really don’t want the message box it’s a nuisance so will probably take it out however I want the checkbox to be automatically checked if payment is overdue but unchecked if up to date –reverting back to checked when 1st September arrives.


I call the function like this in Parent form:-

Private Sub Form_Current()
Me.subPaymentsForm.SetFocus
DoCmd.GoToRecord Record:=acLast

Const conMessage = "Fees are now due for this member." & _
vbNewLine & vbNewLine & "Enter new Payment Record now?"

If Not Me.NewRecord And Me.Expired Then
If NewFeeDue(Me.MemberID, 1, 8, 1) Then
If MsgBox(conMessage, vbYesNo + vbQuestion, "Warning") = vbYes Then
Me.subPaymentsForm.SetFocus
DoCmd.GoToRecord , , acNewRec
Me.subPaymentsForm.Form.AllowAdditions = False
End If
End If
End If

End Sub

And use this to reset it back to false ready for next member:-

Private Sub Expired_AfterUpdate()
Me.subPaymentsForm.Form.AllowAdditions = Not Me.Expired
End Sub
 
If you are using a list format form (ie. more than 1 record visible on screen) then all the checkboxes will be the same allways :( Feature of access....
 

Users who are viewing this thread

Back
Top Bottom