I have the following code where on the load of the form which contains over 100 records I want the checkboxes to be set to false if CSCS/Insurance/passport has expired. The reason for this is even though we may enter another expiry date for the furture I want the system to flag up if we haven't got a physical copy of the new document.
The record count is working however the boxes are not being unchecked.
Private Sub Form_Load()
Dim rst As Recordset
Dim varTotal As Integer
Set rst = CurrentDb.OpenRecordset("All Personal Details", dbOpenDynaset)
' find number of records in your recordset
varTotal = Me.RecordsetClone.RecordCount
MsgBox "Number of loaded records: " & varTotal
rst.MoveFirst
' loop until run out of records
While Not rst.EOF
If [Liability_Expiry] < Now() Then
Me.[CopyofInsurance] = False
End If
If [PassportExpiry] < Now() Then
Me.[Passport] = False
End If
If [CSCS Cards].Form![CSCS Expiry] < Now() Then
Me.[CopyofCSCS] = False
End If
' moves to next record
rst.MoveNext
' one less record to go
varTotal = varTotal - 1
' start loop again
Wend
End Sub
The record count is working however the boxes are not being unchecked.
Private Sub Form_Load()
Dim rst As Recordset
Dim varTotal As Integer
Set rst = CurrentDb.OpenRecordset("All Personal Details", dbOpenDynaset)
' find number of records in your recordset
varTotal = Me.RecordsetClone.RecordCount
MsgBox "Number of loaded records: " & varTotal
rst.MoveFirst
' loop until run out of records
While Not rst.EOF
If [Liability_Expiry] < Now() Then
Me.[CopyofInsurance] = False
End If
If [PassportExpiry] < Now() Then
Me.[Passport] = False
End If
If [CSCS Cards].Form![CSCS Expiry] < Now() Then
Me.[CopyofCSCS] = False
End If
' moves to next record
rst.MoveNext
' one less record to go
varTotal = varTotal - 1
' start loop again
Wend
End Sub