Hi Guys
This one ive been struggling with for ages.
I use the following code to check for dates within 30 days of today for some Fire Certificates from a table called: tblTenancies.
This code works fine but I want it to also check the dates in a second field called: GasCheck and obvisously produce a message box the same for the current FireCheck.
Both FireCheck and GasCheck fields are in the same table: tblTenancies
Can I simply add code into this somehow to ask it to check several fields or is my thinking completely off track?
Thanks
Private Sub Form_Open(Cancel As Integer)
On Error GoTo err
Dim db As DAO.Database
Dim Rst As DAO.Recordset
Set db = CurrentDb
Set Rst = db.OpenRecordset("tblTenancies")
If Rst.EOF Then Exit Sub
Do Until Rst.EOF
If Len(Nz(Rst!FireCheck)) > 0 Then
If DateDiff("d", Now(), Rst!FireCheck) < 30 And DateDiff("d", Now(), Rst!FireCheck) < 30 Then
MsgBox Rst!FireCheck & " : Next Safety/Legal Check(s) Due! (Within 30 Days) ", vbOKOnly, "ALERT! Safety/Legal Check(s) Due "
Else
End If
End If
Rst.MoveNext
Loop
On Error Resume Next
Set db = Nothing
Rst.Close
Set Rst = Nothing
Exit Sub
err:
MsgBox err.Number & ": " & err.Description
End Sub
This one ive been struggling with for ages.
I use the following code to check for dates within 30 days of today for some Fire Certificates from a table called: tblTenancies.
This code works fine but I want it to also check the dates in a second field called: GasCheck and obvisously produce a message box the same for the current FireCheck.
Both FireCheck and GasCheck fields are in the same table: tblTenancies
Can I simply add code into this somehow to ask it to check several fields or is my thinking completely off track?
Thanks
Private Sub Form_Open(Cancel As Integer)
On Error GoTo err
Dim db As DAO.Database
Dim Rst As DAO.Recordset
Set db = CurrentDb
Set Rst = db.OpenRecordset("tblTenancies")
If Rst.EOF Then Exit Sub
Do Until Rst.EOF
If Len(Nz(Rst!FireCheck)) > 0 Then
If DateDiff("d", Now(), Rst!FireCheck) < 30 And DateDiff("d", Now(), Rst!FireCheck) < 30 Then
MsgBox Rst!FireCheck & " : Next Safety/Legal Check(s) Due! (Within 30 Days) ", vbOKOnly, "ALERT! Safety/Legal Check(s) Due "
Else
End If
End If
Rst.MoveNext
Loop
On Error Resume Next
Set db = Nothing
Rst.Close
Set Rst = Nothing
Exit Sub
err:
MsgBox err.Number & ": " & err.Description
End Sub