My problem is, with each iteration of an update loop, I lose about 100k of memory, so eventually, I get an out of resource error after a few thousand iterations.
The question is, why am I losing memory?
Below is a code fragment which is a loop updating data.
The criteria is extracted from a local database, dao.recordset method. -- rs1
The comparison comes from the target database where the update will be done, dao.recordset method. -- rs2 is the target read to see if I need to do an update
The update is a Docmd.Runsql query into a linked sharepoint table. And yes, I know I could use .edit and .update but in that case other strange things happen for a different post. :)
Access 2010 into Sharepoint 2010
Dim db As DAO.Database
Dim rs1 As DAO.Recordset
Dim rs2 As DAO.Recordset
Set db = CurrentDb
Set rs1 = db.OpenRecordset("datefix")
Do While Not rs1.EOF
Set rs2 = db.OpenRecordset("select `Required delivery` from xyzzy where `SO Line` = '" & rs1.Fields(0).Value & "'")
If rs1.Fields(1).Value = rs2.Fields("Required delivery") Then
Else
DoCmd.RunSQL "update ProblemTracking set `Required delivery` = '" & rs1.Fields(1).Value & "', `1st GI Dat` = '" & rs1.Fields(2).Value & "' where `SO Line` = '" & rs1.Fields(0).Value & "'"
End If
rs2.Close
Set rs2 = Nothing
rs1.MoveNext
Loop