Want to query table to get a list of all employees who have had a particular training then take their employee ID's and find them in the Worker table and change the field "Selected" to true. Was able to get it to mark the first record in the Worker table for the recordset but not the rest. Any ideas on what I need to change in my code to get it to modify all of the matching records in the Worker table and the recordset.
Dim CurDB As Database, Rs As Recordset, SQLStmt As String
Dim Rstbl As Recordset
Set CurDB = CurrentDb()
SQLStmt = "SELECT [EmpID], [EmpID] FROM [tblTRAINING] Where Criteria1 And Criteria2"
Set Rs = CurDB.OpenRecordset(SQLStmt, DB_OPEN_DYNASET)
Set Rstbl = CurDB.OpenRecordset("tblWORKER", DB_OPEN_DYNASET)
Do While Not Rs.EOF
Do While Not Rstbl.EOF
If Rs("EmpID" = Rstbl("EmpID" Then
Rstbl.Edit
Rstbl("SELECTED" = True
Rstbl.Update
End If
Rstbl.MoveNext
Loop
Rs.MoveNext
Loop
Rs.Close
Rstbl.Close
End Sub
Thanks for the help in advance,
Mike
Dim CurDB As Database, Rs As Recordset, SQLStmt As String
Dim Rstbl As Recordset
Set CurDB = CurrentDb()
SQLStmt = "SELECT [EmpID], [EmpID] FROM [tblTRAINING] Where Criteria1 And Criteria2"
Set Rs = CurDB.OpenRecordset(SQLStmt, DB_OPEN_DYNASET)
Set Rstbl = CurDB.OpenRecordset("tblWORKER", DB_OPEN_DYNASET)
Do While Not Rs.EOF
Do While Not Rstbl.EOF
If Rs("EmpID" = Rstbl("EmpID" Then
Rstbl.Edit
Rstbl("SELECTED" = True
Rstbl.Update
End If
Rstbl.MoveNext
Loop
Rs.MoveNext
Loop
Rs.Close
Rstbl.Close
End Sub
Thanks for the help in advance,
Mike