You must close any tables that are linked to the backend. That is
sufficient for *you* to disconnect from the backend. Other users of
the backend must be out of the database, too.
I use this function to compact the database (watch for word-wrap), and
watch for application-specific calls to local forms.
Public Sub RunCompact(sFil ePathToCompact As String)
' to compact any MDB file
Dim WorkDir As String
Dim CurrentDatabase Name As String
Dim TargetDatabaseN ame As String
Dim i As Integer
Dim iCount As Integer
' define working directory
i = LastBackslash(s FilePathToCompa ct)
WorkDir = Left$(sFilePath ToCompact, i)
CurrentDatabase Name = Mid$(sFilePathT oCompact, i + 1)
TargetDatabaseN ame = CurrentDatabase Name & ".compact"
' Check if destination database already exists
If Dir(WorkDir & TargetDatabaseN ame) <> "" Then
If MsgBox("Destina tion database " & WorkDir &
TargetDatabaseN ame & " already exists, do you want to delete it?",
vbYesNo, "Confirm") = vbYes Then
Kill WorkDir & TargetDatabaseN ame
Else
MsgBox "Compact procedure exiting"
Exit Sub
End If
End If
' close the main form so that no tables are open
On Error Resume Next
DoCmd.Close acForm, "@frmMain"
' Compact database
DBEngine.Compac tDatabase WorkDir & CurrentDatabase Name, WorkDir &
TargetDatabaseN ame
If Err = 0 Then
' remove old database
Kill WorkDir & CurrentDatabase Name
Name WorkDir & TargetDatabaseN ame As WorkDir &
CurrentDatabase Name
Else
MsgBox "Compacting operation failed, couldn't create new
database file " & WorkDir & TargetDatabaseN ame & vbCrLf & vbCrLf & _
"Nothing has been damaged. Suggest that you exit completely
from LODM then try again. Ensure that nobody else is using the
database." & vbCrLf & vbCrLf & _
"WARNING!! If you have just completed a Restore from
Archive, it is CRITICAL that the backend be " & _
"compacted before adding any new trips. Without compacting,
the TripID sequence will become corrupted.", vbCritical
End If
End Sub
On Fri, 3 Dec 2004 16:10:09 -0000, "ALFRED" <AD*@SPAM.CO.ZA > wrote:
Hi
Using access 2003
I have a front end and back end. I would like to close the connection to the
backend so that I can compact the back end without leaving the front end.
Currently I must exit the datbase and start the repair form from another mdb
that is not connected to the back end.
I have tried
Dim appAccess As Access.Applicat ion
appAccess.Close CurrentDatabase
this gives me an error.
any suggestions
Thanks Alfred
*************** *******
ja************* *@telusTELUS.ne t
remove uppercase letters for true email
http://www.geocities.com/jacksonmacd/ for info on MS Access security