Private Sub Form_Load()
Call CheckForExpiryDates
End Sub
Private Sub CheckForExpiryDates()
Dim rs As Object
Dim rsUnsorted As Object
Dim dtExpireDateUntil As Date
Dim strList As String
Set rsUnsorted = Me.RecordsetClone
dtExpireDateUntil = DateAdd("m", 3, Date)
If Not rsUnsorted.EOF Then
rsUnsorted.Sort = "[LA Expiry]"
Set rs = rsUnsorted.OpenRecordset
With rs
.MoveFirst
Do While Not .EOF
If IsDate(.Fields("LA Expiry")) Then
If .Fields("LA Expiry") <= dtExpireDateUntil And .Fields("LA Expiry") >= Date Then
strList = strList & vbNewLine & "* " & _
.Fields("Site Name") & " (" & .Fields("LA Expiry") & ")"
End If
End If
.MoveNext
Loop
.Close
End With
End If
Set rs = Nothing
Set rsUnsorted = Nothing
If strList <> "" Then
Call MsgBox("These are the list of records that will expire in 3 months time:" _
& vbNewLine & strList, vbInformation)
End If
End Sub
|