V
Vic Spainhower
Hello,
I am trying to use automation to copy some tables from the backend of an
application to a new database. However, it seems like ever method I try
fails because of various limitations. The process needs to be able to run in
a runtime environment (Access 2002) which is currently what is causing me
grief. I'm using the following function to do the copy which works fine when
full access is installed but fails in the runtime environment with error 429
ActiveX component can't create object. However, it is failing on the
GetObject which I thought was supposed to work when starting Access using
Shell.
Can someone offer a solution to this or another method to accomplish same
thing? I'm just tring to create a new database and trhen copy several tables
into it. Seems simple enough and it's driving me nuts!
Vic
Function CreateScheduleDB(strSource As String, strDestination As String) As
Integer
Dim objAccessApp As Object
Dim strCmd As String
On Error GoTo ErrorHandler
DoCmd.Hourglass True
CreateScheduleDB = False
strCmd = SysCmd(acSysCmdAccessDir) & "\MSAccess.exe " _
& Chr(34) & strSource & Chr(34) & " /wrkgrp " & DBEngine.SystemDB
_
& " /user Admin /pwd ''"
Call Shell(strCmd, vbNormal) 'Or use vbHide if you do not want to show
the database
Set objAccessApp = GetObject(strSource)
objAccessApp.DoCmd.CopyObject strDestination, , acTable, "Table1"
objAccessApp.DoCmd.CopyObject strDestination, , acTable, "Table2"
objAccessApp.DoCmd.CopyObject strDestination, , acTable, "Table3"
CreateScheduleDB = True
ExitHere:
On Error Resume Next
objAccessApp.CloseCurrentDatabase
objAccessApp.Quit
DoCmd.Hourglass False
Exit Function
ErrorHandler:
Select Case Err.Number
Case Else
MsgBox "Error Number: " & Err.Number & ", " & Err.Description,
vbCritical, "Unhandled Error"
CreateScheduleDB = False
Resume ExitHere
End Select
I am trying to use automation to copy some tables from the backend of an
application to a new database. However, it seems like ever method I try
fails because of various limitations. The process needs to be able to run in
a runtime environment (Access 2002) which is currently what is causing me
grief. I'm using the following function to do the copy which works fine when
full access is installed but fails in the runtime environment with error 429
ActiveX component can't create object. However, it is failing on the
GetObject which I thought was supposed to work when starting Access using
Shell.
Can someone offer a solution to this or another method to accomplish same
thing? I'm just tring to create a new database and trhen copy several tables
into it. Seems simple enough and it's driving me nuts!
Vic
Function CreateScheduleDB(strSource As String, strDestination As String) As
Integer
Dim objAccessApp As Object
Dim strCmd As String
On Error GoTo ErrorHandler
DoCmd.Hourglass True
CreateScheduleDB = False
strCmd = SysCmd(acSysCmdAccessDir) & "\MSAccess.exe " _
& Chr(34) & strSource & Chr(34) & " /wrkgrp " & DBEngine.SystemDB
_
& " /user Admin /pwd ''"
Call Shell(strCmd, vbNormal) 'Or use vbHide if you do not want to show
the database
Set objAccessApp = GetObject(strSource)
objAccessApp.DoCmd.CopyObject strDestination, , acTable, "Table1"
objAccessApp.DoCmd.CopyObject strDestination, , acTable, "Table2"
objAccessApp.DoCmd.CopyObject strDestination, , acTable, "Table3"
CreateScheduleDB = True
ExitHere:
On Error Resume Next
objAccessApp.CloseCurrentDatabase
objAccessApp.Quit
DoCmd.Hourglass False
Exit Function
ErrorHandler:
Select Case Err.Number
Case Else
MsgBox "Error Number: " & Err.Number & ", " & Err.Description,
vbCritical, "Unhandled Error"
CreateScheduleDB = False
Resume ExitHere
End Select