Search code examples
ms-accessmemory-managementmemory-leaksvbafilesize

Access VBA: Memory control, mdb file size


What are some good practices to control the memory you block up with VBA. For example, I declare objects, open connections, open recordsets, etc, but does that memory get freed again?

When I started the project I'm working on, my Access .mdb file was only 300kb, now its 13Mb!!!! (and its only 300 lines of code) Everytime I run my code, I can see my .mdb file size grow by a few hundred kb.

So please help me out on how I should go about on maintaining my file size.

Thanks!


Solution

  • You can always compact and repair your Access database. In Access 2003 this option is available under Tools > Database Utilities > Compact and Repair.

    The database always increases in size when you are working with it.

    One thing you can always do with VBA is make sure that you Close your connections and recordsets once you are finished using them.