J
Janis
I get an error on the WScript.Quit line. It can't compile. This is
presumably because I ported this script from VBscript to VBA. I want to
compact an Access db from with Access. How can I convert that line to VBA so
I can get this to compile?
tnx,
Public Sub compact()
Dim strMsg
Dim objScript As Object
Dim dbe As DBEngine
Set dbe = CreateObject("dao.dbengine.36")
'path is to System.mdb because it is a split database
dbe.SystemDB = "Z:\SwimClub\System.mdw"
dbe.DefaultUser = "XXXX"
dbe.DefaultPassword = "XXXXX"
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=XXXX"
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 compacting database:"
strMsg = strMsg & vbCrLf & vbCrLf & Err.Description
Call MsgBox(strMsg)
WScript.Quit
End if
On Error GoTo 0
.......................
presumably because I ported this script from VBscript to VBA. I want to
compact an Access db from with Access. How can I convert that line to VBA so
I can get this to compile?
tnx,
Public Sub compact()
Dim strMsg
Dim objScript As Object
Dim dbe As DBEngine
Set dbe = CreateObject("dao.dbengine.36")
'path is to System.mdb because it is a split database
dbe.SystemDB = "Z:\SwimClub\System.mdw"
dbe.DefaultUser = "XXXX"
dbe.DefaultPassword = "XXXXX"
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=XXXX"
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 compacting database:"
strMsg = strMsg & vbCrLf & vbCrLf & Err.Description
Call MsgBox(strMsg)
WScript.Quit
End if
On Error GoTo 0
.......................