Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Growing MS Access File Size problem

I have a large MS Access application with a lot of computations in VBA code. When I run it it eventually crashes due to excessive file size. There are a lot of intermediate tables and queries created and subsequently deleted, but Access does not reclaim the space. I have diligently closed all intermediate record sets and set all temporary objects to nothing, but nothing helps. The only way I can get my code to run is to run part of it, stop and repair/compress the file then restart the code.

Isn't there a better way?

Thanks

like image 853
user55886 Avatar asked Jan 16 '09 16:01

user55886


People also ask

Why does my Access database keep getting bigger?

The database can grow in use, even if you don't save a lot more data. If you use temporary or work tables in the database, then delete their contents after you're done, Access won't be able to recover that space until you compact the database.

How do I reduce file size in Access?

Open MS Access database file. Go to the Database Tools Menu, click on Compact and Repair Database. (This may take some time, which depends on the database file size). As you add, update the data, and change its design, a database file becomes larger.

Does Microsoft Access have a size limit?

General. 2 gigabytes, minus the space needed for system objects. Note: You can work around this size limitation by linking to tables in other Access databases. You can link to tables in multiple database files, each of which can be as large as 2GB.

What causes MS Access database bloat?

Lots of adding and deleting records is one cause of database bloat. If this is your development db, then database bloat is unavoidable as you repeatedly compile and save your vba project; the bloat may be far less pronounced in end-user databases.


1 Answers

You should be able to run the compact function from within your VBA code.

I had the below snippet bookmarked from a long time ago when I was doing access work.

Public Sub CompactDB() 
    CommandBars("Menu Bar").Controls("Tools").Controls("Database utilities").Controls("Compact and repair database...").accDoDefaultAction 
End Sub 

You can put that in your code to get around it.

NOTE: you might also consider growing to a larger db system if you are having these types of scaling issues.

like image 197
Mitchel Sellers Avatar answered Oct 22 '22 11:10

Mitchel Sellers