Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access Compact and Repair from VB

Status
Not open for further replies.

sfunk

Technical User
Jan 22, 2002
107
US
Hello,

Can someone help me with a way for a user of my app to Compact and Repair a Access2000 db. I would like to provide a command button that will do this. My experience level is limited so don't assume I may know obvious things.

Sincerely,
steve
 
One approach would be to use the JRO Objects - add to the project the Jet and Replication Objects library. Then in the click event of the button, something like the following:


Set JRObj = New JRO.JetEngine
JRObj.CompactDatabase "Data Source=c:\olddb.mdb;", "Data Source="c:\newdb.mdb;"
Set JRObj = Nothing

then delete the old db and rename the new one back to the original name Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Our just open the access DB through VB and use the SendKeys command.
 
Thank you. Both approaches sound good. Since I'm not sure which route will work best im my app. Thank you both.

about chadt's response.

When you say open the db through vb do you mean; make a connection and then you ado or something to use the SendKeys command.
 
Hello,

Also, what would the correct way to Dim the object in CajunCenturion's solution.

Dim JRObj As ...

Thanks,
Steve
 
Dim JRObj as JRO.JetEngine
Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
First you have to add a reference to Access (Project...References)

Then to open the DB you would...

'///////////////////////////////////////////////
Dim msAccess As Access.Application
Set msAccess = New Access.Application

msAccess.OpenCurrentDatabase "C:\TEST.mdb"
'//////////////////////////////////////////////

This will open the DB...and then you would have all the functionality that you would if you were in access.

:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top