ACC97: TransferDatabase Causes Page Fault If Object Exists

Last reviewed: September 5, 1997
Article ID: Q160875
The information in this article applies to:
  • Microsoft Access 97

SYMPTOMS

Moderate: Requires basic macro, coding, and interoperability skills.

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:

          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.

           ?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. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

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.

          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 need to execute the function twice to produce 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.

          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.

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 OtpOthr
Version : 97
Platform : WINDOWS
Hardware : x86
Issue type : kbbug
Solution Type : kbworkaround


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 5, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.