Article ID: 926526
Article Last Modified on 10/15/2007
APPLIES TO
- Microsoft Office Access 2007
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:
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.
CAUSE
This problem occurs because the RefreshLink method ignores the table relationships that are created during the previous call to the method.
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:
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
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.
STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.
Additional query words: AC2007 ACC2007 Access2007
Keywords: kbtshoot kbbug kbprogramming kbtable kbcode kbdao kbvba kbexpertiseinter KB926526