Recordset problem #2

rbinder

rbinder
Local time
Tomorrow, 07:00
Joined
Aug 13, 2005
Messages
25
Greetings all,

I seem not to be able to loop through a recordset with the code. When I run the code below it works on the first row but then does not work any further with a error message of 'Object invlaid or no longer set' . I have tried a .update but this does not work.

I have used similar code for single records but cannot work out how to get a recordset with multiple records to work.

The code I am using is;

Dim db As DAO.Database
Dim rs1 As DAO.Recordset, rs2 As DAO.Recordset

Set db = DBEngine(0)(0)

DoCmd.OpenQuery "sqry_Allocation_Edit" ' make table query

Set rs2 = db.OpenRecordset("ztbl_AllocationEdit") 'use that table

Do Until rs2.EOF
rs2.Edit

Set rs1 = db.OpenRecordset("tbl_Admin_Inventory")
rs1.Index = "WineNumber"
rs1.Seek "=", rs2![WINENUMBER]
rs1.Edit
rs1![Allocated] = rs1![Allocated] - rs2![Amount]
rs1.Update
rs1.Connection

rs2.Delete
rs2.Close
Loop


I thank you in advance.

rbinder
 
That looks like xBase programming. Just before the loop I believe you close the wrong RecordSet.
 

Users who are viewing this thread

Back
Top Bottom