Hello:
I am trying to automate a membership status flag based on comparing today's date and a recorded expiry date. The expiry date control is on a sub-form. I have the following code in the OnLoad event of the master form:
Dim DateGap As Integer
While Me.CurrentRecord < Me.Recordset.RecordCount
If Not Me.NewRecord Then
DateGap = DateDiff("y", Date, Forms!PersonalMasterF!MemberSubF.Form.MemberExpire)
Else
DoCmd.GoToRecord , , acNext
End If
If DateGap >= 41 Then
Forms!PersonalMasterF!MemberSubF.Form.MemberActive = "Active"
ElseIf DateGap < 40 And DateGap >= 0 Then
Forms!PersonalMasterF!MemberSubF.Form.MemberActive = "Expiring"
ElseIf DateGap < 0 And DateGap > -60 Then
Forms!PersonalMasterF!MemberSubF.Form.MemberActive = "Expired"
ElseIf DateGap < -61 Then
Forms!PersonalMasterF!MemberSubF.Form.MemberActive = "Inactive"
Else:
Forms!PersonalMasterF!MemberSubF.Form.MemberActive = "Error"
End If
DoCmd.GoToRecord , , acNext
Wend
With debug pointing to the DateGap = statement I get the error 'Invalid use of Null'. As you can see, I've tried to trap any new records it might run into to avoid nulls in MemberExpire, and there are no null values in the MemberExpire field of the underlying table. I've also tried defining DateGap as Variant, which does not work at all. Thoughts?
I am trying to automate a membership status flag based on comparing today's date and a recorded expiry date. The expiry date control is on a sub-form. I have the following code in the OnLoad event of the master form:
Dim DateGap As Integer
While Me.CurrentRecord < Me.Recordset.RecordCount
If Not Me.NewRecord Then
DateGap = DateDiff("y", Date, Forms!PersonalMasterF!MemberSubF.Form.MemberExpire)
Else
DoCmd.GoToRecord , , acNext
End If
If DateGap >= 41 Then
Forms!PersonalMasterF!MemberSubF.Form.MemberActive = "Active"
ElseIf DateGap < 40 And DateGap >= 0 Then
Forms!PersonalMasterF!MemberSubF.Form.MemberActive = "Expiring"
ElseIf DateGap < 0 And DateGap > -60 Then
Forms!PersonalMasterF!MemberSubF.Form.MemberActive = "Expired"
ElseIf DateGap < -61 Then
Forms!PersonalMasterF!MemberSubF.Form.MemberActive = "Inactive"
Else:
Forms!PersonalMasterF!MemberSubF.Form.MemberActive = "Error"
End If
DoCmd.GoToRecord , , acNext
Wend
With debug pointing to the DateGap = statement I get the error 'Invalid use of Null'. As you can see, I've tried to trap any new records it might run into to avoid nulls in MemberExpire, and there are no null values in the MemberExpire field of the underlying table. I've also tried defining DateGap as Variant, which does not work at all. Thoughts?