When I Load a Datasheet Form I am attempting to check every record and 'flag' it if it meets my criteria. Each record consists of a persons name and a long set of qualifications with expiration dates. The code to check the expirations and set the blFlag works as advertised. The Loop I am attempting to set up does not.
I keep getting the following error:
Runtime error 2465: Access can't find the field referenced...referring to this: Set rst = [QualExpiresDatasheetSub2Form].Form.Recordset
This is a valid Form. Also, should I put an error statement in here and at the end zero out the code before exiting the Sub? Thanks for your help.
I keep getting the following error:
Runtime error 2465: Access can't find the field referenced...referring to this: Set rst = [QualExpiresDatasheetSub2Form].Form.Recordset
This is a valid Form. Also, should I put an error statement in here and at the end zero out the code before exiting the Sub? Thanks for your help.
Code:
Private Sub Form_Load()
Dim blFlag As Boolean
Dim Days As Integer, Days1 As Integer, Days2 As Integer, Days3 As Integer, Days4 As Integer, Days5 As Integer, Days6 As Integer, Days7 As Integer, Days8 As Integer, Days9 As Integer, Days10 As Integer, Days11 As Integer
Dim rst As DAO.Recordset
Set rst = [QualExpiresDatasheetSub2Form].Form.Recordset
While Not rst.EOF
' Set flag to False
blFlag = False
' Default date of 12/12/2099 for null value
Days = DateDiff("d", Now, Nz(Me.PhysicalExpires, #12/12/2099#))
Days1 = DateDiff("d", Now, Nz(Me.EFExpires, #12/12/2099#))
Days2 = DateDiff("d", Now, Nz(Me.ADExpires, #12/12/2099#))
Days3 = DateDiff("d", Now, Nz(Me.CExpires, #12/12/2099#))
Days4 = DateDiff("d", Now, Nz(Me.CheckExpires, #12/12/2099#))
Days5 = DateDiff("d", Now, Nz(Me.PhysExpires, #12/12/2099#))
Days6 = DateDiff("d", Now, Nz(Me.SeatExpires, #12/12/2099#))
Days7 = DateDiff("d", Now, Nz(Me.LabExpires, #12/12/2099#))
Days8 = DateDiff("d", Now, Nz(Me.CRMAFExpires, #12/12/2099#))
Days9 = DateDiff("d", Now, Nz(Me.CRMTExpires, #12/12/2099#))
Days10 = DateDiff("d", Now, Nz(Me.TXExpires, #12/12/2099#))
Days11 = DateDiff("d", Now, Nz(Me.ReviewDateExpire, #12/12/2099#))
' Set flag to True if AllRead is checked, default to False if null
blFlag = blFlag Or Nz(Me.AllRead, False)
' Set flag to True if Discrepancies is checked, default to False if null
blFlag = blFlag Or Nz(Me.Discrepancies, False)
' Set flag to True if Days(x) < 14 days
blFlag = blFlag Or (Days < 14)
blFlag = blFlag Or (Days1 < 14)
blFlag = blFlag Or (Days2 < 14)
blFlag = blFlag Or (Days3 < 14)
blFlag = blFlag Or (Days4 < 14)
blFlag = blFlag Or (Days5 < 14)
blFlag = blFlag Or (Days6 < 14)
blFlag = blFlag Or (Days7 < 14)
blFlag = blFlag Or (Days8 < 14)
blFlag = blFlag Or (Days9 < 14)
blFlag = blFlag Or (Days10 < 14)
blFlag = blFlag Or (Days11 < 14)
Me.NewNameLookup = Me.NameLookup
' Add ^ if flag is set to True
If blFlag Then Me.NewNameLookup = Me.NewNameLookup & " ^"
rst.MoveNext
Wend
Form.Refresh
End Sub