By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,104 Members | 1,063 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,104 IT Pros & Developers. It's quick & easy.

Compact an Access database in VB code

P: n/a
Hello,

Can anyone give me some sample VB6 code that compacts and repairs an
Access 2000 database from within a VB app?

Thanks!

Peter Tyler
Geneva - Switzerland

Nov 13 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
On 4 Feb 2005 01:42:37 -0800, PL*****@gmail.com wrote:

Check out the CompactDatabase method. You can use Automation to call
it.
Alternatively you can run a command line; something like:
msaccess.exe mydb.mdb /compact /repair

-Tom.

Hello,

Can anyone give me some sample VB6 code that compacts and repairs an
Access 2000 database from within a VB app?

Thanks!

Peter Tyler
Geneva - Switzerland


Nov 13 '05 #2

P: n/a
Thanks Tom,
Check out the CompactDatabase method. You can use Automation to call it. >>

If I use the following code I get an error message stating "Object
Required".

Private Sub cmdCompact_Click()
DBEngine.CompactDatabase "scholarships.mdb", "scholarships1.mdb"
End Sub
Alternatively you can run a command line; something like:

msaccess.exe mydb.mdb /compact /repair >>

This would surely require that the user has MS Access installed which
is not always the case.

Peter

Nov 13 '05 #3

P: n/a
Peter Tyler wrote:
Thanks Tom,

Check out the CompactDatabase method. You can use Automation to call


it. >>

If I use the following code I get an error message stating "Object
Required".

Private Sub cmdCompact_Click()
DBEngine.CompactDatabase "scholarships.mdb", "scholarships1.mdb"
End Sub


Make sure you have a reference to DAO 3.6

--
This sig left intentionally blank
Nov 13 '05 #4

P: n/a
Check out this link
http://www.mvps.org/access/general/gen0013.htm

Colin

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #5

P: n/a
Thanks Trevor. Works fine now.

I realised there was a library needed somewhere but wasn't sure which
one.

Peter

Nov 13 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.