Wrox Programmer Forums
|
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
 
Old February 21st, 2006, 09:28 AM
Registered User
 
Join Date: Feb 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.
 
Old February 21st, 2006, 11:18 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

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
 
Old February 21st, 2006, 01:11 PM
Registered User
 
Join Date: Feb 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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?
 
Old February 21st, 2006, 04:22 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

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
 
Old February 22nd, 2006, 09:55 AM
Registered User
 
Join Date: Feb 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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?





Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with for-each loop athanatos XSLT 0 April 10th, 2006 07:20 PM
Do Until loop with IF crmpicco Classic ASP Databases 2 June 15th, 2005 05:35 PM
For....Loop kliu9 Excel VBA 5 February 10th, 2005 06:43 AM
Do Loop junemo Beginning PHP 8 July 28th, 2004 02:58 AM
nested while loop doesn't loop hosefo81 PHP Databases 5 November 12th, 2003 08:46 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.