Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there any code to relink Sharepoint tables

Status
Not open for further replies.

Pack10

Programmer
Feb 3, 2010
495
US
Is there any code that will re-link tables. We link to Sharepoint tables, and my manager says the links need
to be refreshed because he noticed the database is not in sync with Sharepoint. So, is there any code that
can do this because i dont want to do this manually.
 
Code:
Sub RefreshSharePointLinks()
  DoCmd.Hourglass True
   Dim dbs As Database
   Dim tbl As TableDef
   Dim SQL As String
   Dim rst As DAO.Recordset
   Set dbs = CurrentDb()
   For Each tbl In dbs.TableDefs
      If (Mid(tbl.Name, 1, 1) <> "~") And ((tbl.Attributes And dbAttachedTable) = dbAttachedTable) Then
         If Left(tbl.Name, 21) <> "User Information List" Then
            If Left(tbl.Connect, 3) = "WSS" Then
               SQL = "SELECT * FROM [" & tbl.Name & "];"
               Set rst = dbs.OpenRecordset(SQL, dbOpenDynaset)
               If Not rst.Updatable Then
                  DoCmd.SelectObject acTable, tbl.Name, True
                  DoCmd.RunCommand acCmdRefreshSharePointList
               End If
            End If
         End If
      End If
   Next
   DoCmd.Hourglass False
End Sub
 
Thank you for the code. Is it possible that Jet will lose the linkage to the Sharepoint tables.
We are not seeing values in our linked tables that are in the Sharepoint table.
Why would this happen?
 
I think the answer is yes. I know that I would routinely show the tables connected, but no data. Then I would "relink". I run this code in a hidden startup form when the db opens and that has solved the problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top