ACC97: TransferDatabase Causes Page Fault If Object Exists

ID: Q160875


The information in this article applies to:
  • Microsoft Access 97

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:

  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:


  4. 
    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 
  5. Save the module as TestXfer and close it.


  6. 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:


  7. Transferred Object: Orders to database file Northwind2.mdb


STATUS

Microsoft has confirmed this to be a problem in Microsoft Access 97.


MORE INFORMATION

Steps to Reproduce Problem

Using a Visual Basic Procedure

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.


  4. 
          Function XferError()
             DoCmd.TransferDatabase acExport, "Microsoft Access", _
                  "Northwind2.mdb", acForm, "Orders", "Orders", False
          End Function 
  5. Save the module as Module1 and close it.


  6. 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.


Using a Macro

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.


  4. 
          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 
  5. Save the XferError macro and close it.


  6. 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.



REFERENCES

For more information about TransferDatabase, search the Help Index for "TransferDatabase method" or "TransferDatabase action," or ask the Microsoft Access 97 Office Assistant.

Additional query words: IPF OutputTo xfer GPF

Keywords : kberrmsg kbprg AccCon OtpOthr
Version : WINDOWS:97
Platform : WINDOWS
Issue type : kbbug


Last Reviewed: November 1, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.