One more question...
I am passing a record identified to the function so I only want to perform the "for each" "loop" (for lack of a better term). How do I tell the recordset to only look through the fields for that one record as opposed to all records in the table?
Here is my code for the filter, but the filter does not work. I tried setting the rs back to itself again because I read you had to do that. I have tried without setting it back to itself and it still doesn't work.
Code:
Function funUpdateWeeks(emplID As Long, emplDate As Date)
Dim varField As Field
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim rs1 As DAO.Recordset
Dim i As Integer
Dim varWeekVal, varExemptVal
Set db = CurrentDb
Set rs = db.OpenRecordset("tblExempt", dbOpenDynaset)
Set rs1 = db.OpenRecordset("SLAUDIT_FDT_SA_EXCP_SUMM_DIST", dbOpenDynaset)
'rs.FindFirst "[EmplID] = " & emplID
rs.Filter = "[EmplID] = " & emplID
Set rs = db.OpenRecordset("tblExempt", dbOpenDynaset)
i = -2
For Each varField In rs.Fields
'Check to see if week date = trans_date
i = i + 1
If i > 0 Then
varWeekVal = rs("Week" & i)
If DatePart("ww", varWeekVal) = DatePart("ww", emplDate) Then
If DatePart("yyyy", varWeekVal) = DatePart("yyyy", emplDate) Then
rs.Edit
rs("Exempt" & i).Value = -1
rs.Update
End If
End If
End If
Next varField
rs.Close
rs1.Close
End Function