ok, the setup. I have two queries. UpdateGrads and CurrentGradList. UpdateGrads in a non-updateable query. CurrentGradList is an updateable query. There are 7 records in currentGradList and 2 records in updateGrads. (kept the queries small for testing.) The code below is what I use (and have used on several occasions before.) to update a non-updateable query. (Basically updating the second query based of the records of the non-updateable one.)
The problem. The second loop appears to be infinite. Even though I am 100% positive there are only 2 records in the query, it will continue to loop until I manually break it. Here's what happends. I run the code, msgboxes pop up in the following order
RS2 0
RS 0
RS 1
RS 2
RS 3
RS 4
RS 4
... and so on until i break it.
Anyone see my error in the code below, I've been racking my brain trying to find it and I'm coming up with squat..
Code:Dim DB As DAO.Database Dim RS As DAO.Recordset Dim RS2 As DAO.Recordset Dim i As Integer Dim x As Integer Set DB = CurrentDb Set RS = DB.OpenRecordset("UPdateGrads") Set RS2 = DB.OpenRecordset("CurrentGradList") If RS.RecordCount <> 0 Then RS.MoveFirst RS2.MoveFirst Do While Not RS2.EOF MsgBox "RS2 " & i Do While Not RS.EOF MsgBox "RS " & x If RS.Fields("StudentID") = RS2.Fields("StudentID") Then RS2.Edit RS2.Fields("StatusCode") = 201 RS2.Fields("NextClass") = Null RS2.Fields("CurrentInstructor") = Null RS2.Fields("req1") = Null RS2.Fields("req2") = Null RS2.Fields("req3") = Null RS2.Fields("req4") = Null RS2.Fields("req5") = Null RS2.Fields("req6") = Null RS2.Fields("req7") = Null RS2.Fields("LDA") = RS2.Fields("GradDate") RS2.Update End If x = x + 1 RS.MoveNext Loop i = i + 1 x = 0 RS.MoveFirst RS2.MoveNext Loop End If Set DB = Nothing Set RS = Nothing Set RS2 = Nothing MsgBox "Done"




