J
Janis
I have this compact script which successfully runs. The script is in a
module in the front-end db and it compacts the back-end db while the file is
closed. I keep getting the "compact successful" dialogue box at the end of
it running but I don't see any movement in the folder or the db being
compacted. I don't see the copy file manipulations. How can I set some
debug variables or break points so I can get some useful informaiton?
Thank you very much,
----
Option Explicit
Option Compare Database
Public Sub compact()
Dim strMsg
Dim objscript
Dim dbe
Set dbe = CreateObject("dao.dbengine.36")
'Me.dbe = CreateObject("dao.dbengine.36")
'path is to System.mdb because it is a split database
dbe.SystemDB = "Z:\SwimClub\System.mdw"
dbe.DefaultUser = "Brian"
dbe.DefaultPassword = "Kiyote#3"
On Error GoTo 0
'perform db compact of backend mdb into a temp mdb first
'if there is a problem the origial mdb is preserved
dbe.CompactDatabase "Z:\SwimClub\acsc_be.mdb",
"Z:\SwimClub\temp_acsc_be.mdb", , , ";pwd=Kiyote#3"
If (Err.Number <> 0) Then
On Error GoTo 0
' There was an error. Inform the user and halt execution
strMsg = "The following error was encountered while compactingdatabase:"
strMsg = strMsg & vbCrLf & vbCrLf & Err.Description
Call MsgBox(strMsg)
objscript.Quit
End If
On Error GoTo 0
' Create File System Object to handle file manipulations
Set objscript = CreateObject("Scripting.FileSystemObject")
' Back up the original file as Filename.mdbz. In case of undetermined
' error, it can be recovered by simply removing the terminating "z".
objscript.CopyFile "Z:\SwimClub\acsc_be.mdb", "Z:\SwimClub\acsc_be.mdb" &
"z", True
' Copy the compacted mdb by into the original file name
objscript.CopyFile "Z:\SwimClub\temp_acsc_be.mdb",
"Z:\SwimClub\acsc_be.mdb", True
' We are finished with TempDB. Kill it.
objscript.DeleteFile "Z:\SwimClub\temp_acsc_be.mdb"
Call MsgBox("compact successful")
End Sub
module in the front-end db and it compacts the back-end db while the file is
closed. I keep getting the "compact successful" dialogue box at the end of
it running but I don't see any movement in the folder or the db being
compacted. I don't see the copy file manipulations. How can I set some
debug variables or break points so I can get some useful informaiton?
Thank you very much,
----
Option Explicit
Option Compare Database
Public Sub compact()
Dim strMsg
Dim objscript
Dim dbe
Set dbe = CreateObject("dao.dbengine.36")
'Me.dbe = CreateObject("dao.dbengine.36")
'path is to System.mdb because it is a split database
dbe.SystemDB = "Z:\SwimClub\System.mdw"
dbe.DefaultUser = "Brian"
dbe.DefaultPassword = "Kiyote#3"
On Error GoTo 0
'perform db compact of backend mdb into a temp mdb first
'if there is a problem the origial mdb is preserved
dbe.CompactDatabase "Z:\SwimClub\acsc_be.mdb",
"Z:\SwimClub\temp_acsc_be.mdb", , , ";pwd=Kiyote#3"
If (Err.Number <> 0) Then
On Error GoTo 0
' There was an error. Inform the user and halt execution
strMsg = "The following error was encountered while compactingdatabase:"
strMsg = strMsg & vbCrLf & vbCrLf & Err.Description
Call MsgBox(strMsg)
objscript.Quit
End If
On Error GoTo 0
' Create File System Object to handle file manipulations
Set objscript = CreateObject("Scripting.FileSystemObject")
' Back up the original file as Filename.mdbz. In case of undetermined
' error, it can be recovered by simply removing the terminating "z".
objscript.CopyFile "Z:\SwimClub\acsc_be.mdb", "Z:\SwimClub\acsc_be.mdb" &
"z", True
' Copy the compacted mdb by into the original file name
objscript.CopyFile "Z:\SwimClub\temp_acsc_be.mdb",
"Z:\SwimClub\acsc_be.mdb", True
' We are finished with TempDB. Kill it.
objscript.DeleteFile "Z:\SwimClub\temp_acsc_be.mdb"
Call MsgBox("compact successful")
End Sub