devxlogo

Reattach and Refresh SQL Links

Reattach and Refresh SQL Links

You often need to reattach or refresh links in Microsoft Access. This code refreshes all currently linked tables to sync the attached tables with the server, then remove “dbo_” from all attached SQL Server tables. The two table Def loops allow you to re-sync tables after “dbo_” is removed:

 Dim tbDef As TableDefDim db As DatabaseDim strDBLocation As StringOn Error Resume NextCommonDialog1.ShowOpenstrDBLocation = CommonDialog1.FileNameIf strDBLocation = "" Then	EndEnd IfSet db = OpenDatabase(strDBLocation)For Each tbDef In db.TableDefs	' Refresh table links		db.TableDefs(tbDef.Name).RefreshLinkNext tbDefFor Each tbDef In db.TableDefs' Remove all dbo_'s from tablesIf Left(tbDef.Name, 4) = "dbo_" Then	tbDef.Name = Mid(tbDef.Name, 5, Len(tbDef.Name) - 4)End IfNext tbDef
See also  5 Tips for Choosing the Right Medical Software for Your Practice
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist