Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Record Sets for loops in VBA code

Status
Not open for further replies.

mini1969

Programmer
Feb 26, 2005
13
0
0
BA
The following is the structure for VBA SQL application for Access 2000 dtatabse.
Code:
-------------------------------------
Open table 1, collect a parameter set **
Open table 2, collect a parameter set **

Loop1: For each table1 parameter

Loop2: For each table2 parameter
Open a source data table **

Loop 3: Search the record set
Calculate sum of a field on another Field condition
Set the parameter for used data in record set
Update parameter
Close the source data record set

Open table_destination_data , **
Update the table with values of Sum and parameters
on which it was calculated
End Loop 3

End Loop2

End Loop1
-----------------------------------------------
All the ** indicates opening of a record set pointing to tables (all in same database)

QUESTION:

Is it possible to open multiple record set from VBA code to calculate the required summary and update it into another table?
Will these multiple loops cause any problem with record set?
Any other suggestions to achieve this in a better way!
 
Some times we ourself post the question and find the answer. I tried the above problem and came out with an easy solution. In loops I was opening the recordset, but closing not properly before again opening. Once i closed the recordset before reopening everytimein the loop, every thing works fine!

hope this is useful to some one

Mini
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top