 |
| Access VBA Discuss using VBA for Access programming. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

February 21st, 2006, 09:28 AM
|
|
Registered User
|
|
Join Date: Feb 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Please help with loop...
I am looping through a large Access recordset (200000 records) and performing a process every 50 records. Loop through 50 records, perform process, loop through next 50, perform process, loop through next 50... and so on. I run out of memory after about 150 loops. Should I close the recordset after each loop? What is the correct approach to this? Any help is greatly appreciated by a VBA newbie.
|
|

February 21st, 2006, 11:18 AM
|
|
Friend of Wrox
|
|
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
|
|
What are you doing that requires this much memory? And how much memory do you have? Where is the processing going on? Is this a desktop solution, client server, SQL server, ? etc.
What are you doing every 50 records? You can also try pulling your data 50 records at a time, then doing your transaction, dump the recordset, and then pull the next 50 etc.
mmcdonal
|
|

February 21st, 2006, 01:11 PM
|
|
Registered User
|
|
Join Date: Feb 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
This is a desktop solution (MS Access.) It loops through 50 records (builds an In-Statement) and inserts it into SQL. The SQL is run against a table via ODBC. Once the query is returned, I go back and get the next 50. It works for awhile but then...
I like the idea of dumping and repulling. What is the best way to accomplish this? rst.close?
|
|

February 21st, 2006, 04:22 PM
|
|
Friend of Wrox
|
|
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
|
|
I'm not sure I understand.
Loops through 50 records and builds an in-statement. What is an "In-Statement?"
The SQL is run against a table?
You should be dumping the recordsets after each loop, rst.Close, or rst = Nothing. You can leave the connection open.
Can you give me more structure?
mmcdonal
|
|

February 22nd, 2006, 09:55 AM
|
|
Registered User
|
|
Join Date: Feb 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Sorry about the vagueness. It loops through 50 records and builds SQL like this: SELECT Accounts FROM Customers WHERE Account_Number In('1111','2222','3333'). The account numbers are from a local table. The SQL is then run against a data warehouse via ODBC. Our data warehouse can't link to local tables, so I am forced to use this method to query those tables
When I close the recordset after a loop, will it hold my place? For instance if I run through the first 50, then rst.close, what is the best way to pick back up where I left off? How do I start my next loop at record 51?
|
|
 |