ACC97: TransferDatabase Causes Page Fault If Object Exists (160875)
The information in this article applies to:
This article was previously published under Q160875 Moderate: Requires basic macro, coding, and interoperability skills.
SYMPTOMS
When you use TransferDatabase to copy an object to a target database, you
may receive the following error message if the target database already
contains the same type of object with the same name:
Object invalid or no longer set.
That message is followed by an invalid page fault which causes Microsoft
Access to shut down:
MSACCESS caused an invalid page fault in module MSJET35.DLL
This article assumes that you are familiar with Visual Basic for
Applications and with creating Microsoft Access applications using the
programming tools provided with Microsoft Access. For more information
about Visual Basic for Applications, please refer to the "Building
Applications with Microsoft Access 97" manual.
RESOLUTION
To work around the error, test for the existence of the object in the
target database and delete it before you use TransferDatabase, as in the
following example:
- Create a copy of the sample database Northwind.mdb as Northwind2.mdb.
- Open the sample database Northwind.mdb.
- Create a module and type the following procedure:
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
- Save the module as TestXfer and close it.
- To test this function, type the following line in the Debug window,
and then press ENTER.
NOTE: Type the full path and file name for Northwind2.mdb as the first
parameter in the following function.
?TransferObject("Northwind2.mdb", acForm, "Orders")
Note that when the transfer is complete, you receive the message:
Transferred Object: Orders to database file Northwind2.mdb
STATUS
Microsoft has confirmed this to be a problem in Microsoft Access 97.
REFERENCES
For more information about TransferDatabase, search the Help Index for
"TransferDatabase method" or "TransferDatabase action," or ask the
Microsoft Access 97 Office Assistant.
Modification Type: | Minor | Last Reviewed: | 10/11/2006 |
---|
Keywords: | kbbug kberrmsg kbProgramming KB160875 |
---|
|