I need to copy several objects to other databases.
I have managed to do this but experience errors if the object already exists.
The code below is a modified sample from Microsoft and it works, in that it deletes the object before the copy but it uses the OpenCurrentDatabase method to do this. This causes code to run in databases where there are autoexec macros or forms with code etc which run on open.
I need to know if there is someway to do this using the OpenDatabase method so the code in the other database is not activated.
Public Function TransferObject(Filename As String, _
objType As Integer, objName As String)
On Error Resume Next
Dim accObj As New Access.Application
accObj.OpenCurrentDatabase Filename
accObj.DoCmd.DeleteObject objType, objName
accObj.CloseCurrentDatabase
Set accObj = Nothing
DoCmd.TransferDatabase acExport, _
"Microsoft Access", Filename, objType, objName, _
objName, False
End Function
I have managed to do this but experience errors if the object already exists.
The code below is a modified sample from Microsoft and it works, in that it deletes the object before the copy but it uses the OpenCurrentDatabase method to do this. This causes code to run in databases where there are autoexec macros or forms with code etc which run on open.
I need to know if there is someway to do this using the OpenDatabase method so the code in the other database is not activated.
Public Function TransferObject(Filename As String, _
objType As Integer, objName As String)
On Error Resume Next
Dim accObj As New Access.Application
accObj.OpenCurrentDatabase Filename
accObj.DoCmd.DeleteObject objType, objName
accObj.CloseCurrentDatabase
Set accObj = Nothing
DoCmd.TransferDatabase acExport, _
"Microsoft Access", Filename, objType, objName, _
objName, False
End Function