I generate an unmatched query in my vba code. I then open the recordset in vba to determine if I need to remove one of the records I don't want to appear in the subsequent report.
Here's the code snippet I use: Emp comes over as a parameter in this function, named ChkJobCodes.
The "qryMonthJobCodes Without Matching tblJobs" query is created earlier in the function
I tried putting rs.update after the rs.delete statement. But got an error saying there was no Addition or Edit.
Any suggestions are welcomed.
Thanks,
Vic
Here's the code snippet I use: Emp comes over as a parameter in this function, named ChkJobCodes.
The "qryMonthJobCodes Without Matching tblJobs" query is created earlier in the function
Code:
Dim rs as DAO.Recordset
Dim i as Integer, rcnt as Integer
Dim JCd as String
Set rs = db.OpenRecordset("qryMonthJobCodes Without Matching tblJobs", dbOpenDynaset)
rs.MoveLast
If rs.RecordCount > 0 Then
rs.MoveFirst
If Emp = "Tal" Then
For i = 1 To rs.RecordCount
JCd = rs.Fields(0).Value
If Left(JCd, 6) = "unassi" Then [COLOR=#4E9A06]'If present, this record should always be last in the recordset[/color]
rs.Delete
rcnt = rs.RecordCount
rs.Close
GoTo lpout [COLOR=#4E9A06]'Have to jump out in case that was last record; the MoveNext would throw an error[/color]
End If
rs.MoveNext
Next i
lpout:
If rcnt = 0 Then GoTo cleanup
End If
DoCmd.OpenReport "rptMissingJobCodes", acViewPreview
ChkJobCodes = "True"
Exit Function
I tried putting rs.update after the rs.delete statement. But got an error saying there was no Addition or Edit.
Any suggestions are welcomed.
Thanks,
Vic