Click to See Complete Forum and Search --> : Access Database Utilities


valkyrie
January 17th, 2000, 01:02 AM
Hi all,
Here is a stupid post. If I wanted to compact my Access database (Access 97) via VB, how do I go about it? I've created a reference to the Access object, but am not sure how to call this command.
Thanks for your help.


____________________________________
The VB Bugs in my Life...

Lothar Haensler
January 17th, 2000, 01:16 AM
add a reference to DAO to your project and call the CompactDatabase method of the DBEngine object.

valkyrie
January 17th, 2000, 01:50 AM
Hi again,
Forgot to mention that I am using ADO and not DAO, and I did try the CompactDatabase method via the DBEngine, but VB kept complaining about the application being open.
The question is, do I have to close my ADO connection first before doing this?
Thanks again

____________________________________
The VB Bugs in my Life...

Lothar Haensler
January 17th, 2000, 01:53 AM
ok, try this: MSDN article Q230501 describes how to compact a database via ADO:
you need to use "Microsoft Jet OLE DB Provider and Replication Objects (JRO). "
which comes with Jet 4...
check out the article it has all: source code and so on.

valkyrie
January 17th, 2000, 03:43 AM
Thanks Lothar,
Found out why VB complained about my code. My ADO connection object was left open. So, I closed it and the code worked!!! Another bug I found was that I was compacting the database and used the same MDB file as the output.
Thanks for your help!

____________________________________
The VB Bugs in my Life...