Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - strPathtoMDB path changed from mdb to the System file(runtime error)

Reply
 
Old 06-08-2009   #1 (permalink)
JRough


 
 

strPathtoMDB path changed from mdb to the System file(runtime error)

I have one test script that works so I know all the paths are right
and the workgroup file works and the passwords allow the script to
run. I would like to use my script below instead because it has
error checking, messages for the user & copies the file before
compacting. It is a split database and I only want to compact the
backend. That is why I have to open the system workgroup file not the
mdb file. The first script doesn't work if I change the 2nd line to
the mdb file.

set dbe = createobject("dao.dbengine.36")
dbe.SystemDB="Z:\SwimClub\System.mdw"
dbe.DefaultUser = "Brian"
dbe.DefaultPassword ="Kiyote#3"
dbe.CompactDatabase "Z:\SwimClub\acsc_be.mdb","Z:\SwimClub
\compact_acsc_be2.mdb",,,";pwd=Kiyote#3"

So I changed the strPathtoMDB variable to the SYSTEM workgroup file,
not the mdb file, on the first line of code below. The script
doesn't work. I get the error 'Runtime error object doesn't support
this property or method "default user" '. So this script below won't
accept the System.mdw file to check for the user and password when the
one above does? Is the strPathtoMDB a hardwired variable? So is
this script below only going to accept the mdb file as the connection
not the System.mdw file for some reason or can I change it someway.
Tnx,


Option Explicit
Dim objScript
Dim objAccess
Dim strPathToMDB
Dim strMsg
Dim strTempDB

strPathToMDB = "Z:\SwimClub\SYSTEM.mdb"

strTempDB = "Z:\SwimClub\Comp0001.mdb"
Set objAccess = CreateObject("Access.Application.11")
objAccess.DefaultUser = "BRIAN"
objAccess.DefaultPassword = "Kiyote#3"

On Error GoTo 0
objAccess.DBEngine.CompactDatabase strPathToMDB, strTempDB
If (Err.Number <> 0) Then
On Error GoTo 0
'
strMsg = "The following error was encountered while
compactingdatabase:"
strMsg = strMsg & vbCrLf & vbCrLf & Err.Description
Call MsgBox(strMsg)
Wscript.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 strPathToMDB, strPathToMDB & "z", True

' Copy the compacted mdb by into the original file name
objScript.CopyFile strTempDB, strPathToMDB, True

' We are finished with TempDB. Kill it.
objScript.DeleteFile strTempDB
Call MsgBox("compact successful")

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Windows installer - Error: 80070641 and Error 3: System cannot find path specified Windows Updates
Windows installer - Error: 80070641 and Error 3: System cannot find path specified General Discussion
Re: VBScript runtime error: Variable is undefined: 'System' VB Script
System file COMCTL32.OCX changed inadvertantly Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46