Code to compact and repair

G

Guest

I would like to compact and repair 3 other databases from one control
panel(switchboard). Does anyone know or have the code to compact and repair a
database? I would like to put it behind a button.

I also have another question. How come access wont open another database
from a different database using the wizard? I gave it the network path and
everything but it will not work. More concerned with the code for the compact
and repair though!
 
6

'69 Camaro

Hi, Troy.
Does anyone know or have the code to compact and repair a
database? I would like to put it behind a button.

Use the Shell method. Try (watch out for word wrap):

Public Sub compactOtherDB()

On Error GoTo ErrHandler

Dim sCmd As String
Dim rtn As Double

sCmd = Chr$(34) & "C:\Program Files\Microsoft
Office\OFFICE11\MSACCESS.EXE" & _
Chr$(34) & " " & Chr$(34) & "C:\MyDB.mdb" & Chr$(34) & " /compact"
rtn = Shell(sCmd, vbHide)

Exit Sub

ErrHandler:

MsgBox "Error in compactOtherDB( )." & _
vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description
Err.Clear

End Sub
How come access wont open another database
from a different database using the wizard?

The wizard is designed to compact the current database, unless one isn't
currently open. In that case, the user is prompted to browse for the
database to compact.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact
info.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top