You are here:

Using MS Access/Functionality Question Regarding Macros and Memory

Advertisement


Question
QUESTION: I am writing macros run the query dump the query info into a table and then export it in an excel spreadsheet.

I am finding that this is making the database quite huge and causing issues is there any way to ensure that the function relinquishes control and closes the macro so that I can cut down on memory space being hogged by access?

Thanks
Tana

ANSWER: Running macros has no affect on database size, but it could be using up RAM.

What is making the database huge is creating temp tables. That is unnecessary. You don't need to run a macro or create a temporary table to export to Excel. The TransferSpreadsheet command will output the results of a query to Excel. So all you need is the one command, TransferSpreadsheet.

Hope this helps,
Scott<>
Blog: http://scottgem.wordpress.com
Website: http://www.diamondassoc.com
Microsoft Access MVP 2007
Author: Microsoft Office Access 2007 VBA


---------- FOLLOW-UP ----------

QUESTION: Where does that go within the query itself or is that something I need to use VBA code for??

ANSWER: You can do it in a macro or (preferably) VBA code. Depending on your version of Access, the command for export to Excel changed in 2010 macros. In 2010 its ImportExportSpreadsheet. For VBA or pre 2010 macros it is TransferSpreadsheet.

Hope this helps,
Scott<>
Blog: http://scottgem.wordpress.com
Website: http://www.diamondassoc.com
Microsoft Access MVP 2007
Author: Microsoft Office Access 2007 VBA

---------- FOLLOW-UP ----------

QUESTION: Yes I am using Access 2010.  Could you use one of the actions available to utilize the command:

Data Entry Operations
Data Import/Export
Database Objects
Filer/Query/Search
Macro Commands
System Commands
User Interface Commands
Window Management

Answer
Under Data Import/Export will be ImportExportSpreadsheet. You may need to Select the Show All Actions.

But frankly, I would do this in a VBA module since its is only one line of code.

Hope this helps,
Scott<>
Blog: http://scottgem.wordpress.com
Website: http://www.diamondassoc.com
Microsoft Access MVP 2007
Author: Microsoft Office Access 2007 VBA

Using MS Access

All Answers


Answers by Expert:


Ask Experts

Volunteer


Scottgem

Expertise

I can answer almost all types of questions relating to Microsoft Access usage and application design. My strengths are database and interface design.

Experience

I've been designing databases for over 25 years working with dBase, FoxPro, Approach and Access.

Organizations
Author of Microsoft Office Access 2007 VBA
Techncial Editor for Special Edition Using Microsoft Access 2007 and Access 2007 Forms, Reports & Queries From Que Publishing

Education/Credentials
Brooklyn College BA

©2016 About.com. All rights reserved.