You may experience a GPF when trying to export an object
to another database by using TransferDatabase method. This page
fault occurs if the destination object (any valid Access object type) already
exists.
The only solution at present is to use Automation to start
a new Access instance and delete the destination object before issuing the
TransferDatabase command.
160875: TransferDatabase causes page fault if object exists.
This code has been copied from the aforementioned Support article.
Public Function TransferObject(Filename As String, _
objType As Integer, _
objName As String)
On Error GoTo TransferObject_Err
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
MsgBox "Transferred Object: " & objName & _
" to database file " & Filename, _
vbInformation, "Test"
TransferObject_End:
Exit Function
TransferObject_Err:
MsgBox Err.Description, vbCritical, "Test"
Resume TransferObject_End
End Function
|