Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

Error message when you try to open a linked SharePoint table in Access 2007: "The Microsoft Office Access database engine could not find the object"


Symptoms

When you try to open a linked Microsoft Windows SharePoint Services table in Microsoft Office Access 2007, you may receive an error message that resembles the following error message:
The Microsoft Office Access database engine could not find the object 'Object name'. Make sure the object exists and that you spell its name and the path name correctly.
However, the linked SharePoint table opens successfully.

This error message occurs after you update the linked SharePoint table programmatically more than one time in a row by using the Data Access Objects (DAO) RefreshLink method.

↑ Back to the top


Cause

This problem occurs because the RefreshLink method ignores the table relationships that are created during the previous call to the method.

↑ Back to the top


Workaround

To work around this problem, programmatically delete the table relationships before you use the RefreshLink method to update the linked table.

Sample subroutine to delete the relationships

To use a subroutine to delete the relationships for the refreshed link, follow these steps:
  1. Insert the following code into a module in Microsoft Visual Basic for Applications (VBA):
    Public Sub RemoveInvalidRelationships(strTableName As String)
    On Error Resume Next
    Dim cnt As Integer
    Dim i As Integer
    Dim bForeignTable As Boolean
    Dim bTable As Boolean
    Dim td As TableDef

    cnt = CurrentDb.Relations.Count - 1
    ' Go through the relationships collection backwards, to ensure that if we delete one, we will have a valid index
    For i = cnt To 0 Step -1
    bTable = False
    bForeignTable = False
    If (StrComp(CurrentDb.Relations(i).Table, strTableName, vbTextCompare) = 0) Then bTable = True
    If (StrComp(CurrentDb.Relations(i).ForeignTable, strTableName, vbTextCompare) = 0) Then bForeignTable = True

    If bTable Xor bForeignTable Then
    ' Determine if either the table or foreign table is the table that we are interested in
    ' We will then look at the other table to determine if it exists
    ' If it doesn't exist, delete the relationship
    If bTable Then
    Set td = CurrentDb.TableDefs(CurrentDb.Relations(i).ForeignTable)
    Else
    Set td = CurrentDb.TableDefs(CurrentDb.Relations(i).Table)
    End If

    If Err.Number = 3265 Then
    CurrentDb.Relations.Delete CurrentDb.Relations(i).Name
    End If
    Err.Clear
    End If

    Next i
    End Sub
  2. In the source code where the RefreshLink method is called, insert the following code immediately before the RefreshLink source code line:
    RemoveInvalidRelationships "WSSLink"
    Note "WSSLink" is the name of the linked table that is being refreshed by the RefreshLink method.

↑ Back to the top


Status

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

↑ Back to the top


Keywords: kbprogramming, kbtable, kbvba, kbdao, kbbug, kbcode, kbentirenet, kbtshoot, kbexpertiseinter, kb

↑ Back to the top

Article Info
Article ID : 926526
Revision : 1
Created on : 1/7/2017
Published on : 10/15/2007
Exists online : False
Views : 158