This article was previously published under Q160875
Moderate: Requires basic macro, coding, and interoperability skills.
On This Page
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.
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:
1.
Create a copy of the sample database Northwind.mdb as Northwind2.mdb.
2.
Open the sample database Northwind.mdb.
3.
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
4.
Save the module as TestXfer and close it.
5.
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.
WARNING: Following these steps will cause an invalid page fault on your
computer. Make sure you save and close any open work on your computer
before following these steps.
1.
Create a copy of the sample database Northwind.mdb as Northwind2.mdb.
2.
Open the sample database Northwind.mdb.
3.
Create a module and type the following procedure.
NOTE: Type the full path and file name for Northwind2.mdb in the
Database Name argument of the TransferDatabase method in this example.
Function XferError()
DoCmd.TransferDatabase acExport, "Microsoft Access", _
"Northwind2.mdb", acForm, "Orders", "Orders", False
End Function
4.
Save the module as Module1 and close it.
5.
To test this function, type the following line in the Debug window,
and then press ENTER:
?XferError()
Note that you may have to execute the function twice to produce the invalid page fault error.
WARNING: Following these steps will cause an invalid page fault on your
computer. Make sure you save and close any open work on your computer
before following these steps.
1.
Create a copy of the sample database Northwind.mdb as Northwind2.mdb.
2.
Open the sample database Northwind.mdb.
3.
Create the following new macro.
NOTE: Type the full path and file name for Northwind2.mdb in the
Database Name argument of the TransferDatabase action in this example.
Macro: XferError Action
--------------------------------------
TransferDatabase
XferError Actions
----------------------------------
TransferDatabase
Transfer Type: Export
Database Type: Microsoft Access
Database Name: Northwind2.mdb
Object Type: Form
Source: Orders
Destination: Orders
Structure Only: No
4.
Save the XferError macro and close it.
5.
Run the macro. You may need to run the macro twice to produce the
following error message:
Object Invalid or no longer set.
When you click OK in response to the error message, you receive the
invalid page fault error.
For more information about TransferDatabase, search the Help Index for
"TransferDatabase method" or "TransferDatabase action," or ask the
Microsoft Access 97 Office Assistant.
Need More Help? Contact a Support professional by Email, Online or Phone.
Customer Service For non-technical assistance with product purchases, subscriptions, online services, events, training courses, corporate sales, piracy issues, and more.
Newsgroups Pose a question to other users. Discussion groups and Forums about specific Microsoft products, technologies, and services.