Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Intermediate
Apr 6, 2000

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 TableDef
Dim db As Database
Dim strDBLocation As String
On Error Resume Next
CommonDialog1.ShowOpen
strDBLocation = CommonDialog1.FileName
If strDBLocation = "" Then
	End
End If
Set db = OpenDatabase(strDBLocation)
For Each tbDef In db.TableDefs
	' Refresh table links
		db.TableDefs(tbDef.Name).RefreshLink
Next tbDef
For Each tbDef In db.TableDefs
' Remove all dbo_'s from tables
If Left(tbDef.Name, 4) = "dbo_" Then
	tbDef.Name = Mid(tbDef.Name, 5, Len(tbDef.Name) - 4)
End If
Next tbDef
Michael Finley
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date