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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linked Tables

Status
Not open for further replies.

PinkPanther2070

Programmer
Jan 11, 2002
3
US
How do you change the path on a linked table?

Thanks
Pinkpanther
 
Do you mean - change the path by some other method besides using the Linked Table Manager? If so, no clue.

The location of the Linked Table Manager depends on which version of Access you're using. In 2000 and XP, it's under Tools, Database Utilities. -hmm
-Using AccessXP
 
I have tables that have been linked to another computer ie://computername/path..., and so if this computer is not accessible the tables do not open. So I would like to either unlink the tables or give it a new path name.
 
While in the Visual Basic Editor, go into the help files and search for "SourceTableName Property". Has example code on how to set the sources (linked tables) using VB. Could build in some If/Then code to determine if the other user's computer is accessible; hard-code the path to an alternate location when it's not. (??)

Don't know if that will help or not. -hmm
-Using AccessXP
 
This code might help you to let the user do the table link via the application:

Dim resval As Integer
Dim strMsg As String

FileDialog.FileName = "*.mdb"
FileDialog.Flags = "&H1000" Or "&H4" 'cdlOFNFileMustExist Or cdlOFNHideReadOnly
resval = FileDialog.ShowOpen()
If Err.Number = 32755 Then
Exit Sub
End If
If FileDialog.FileName = "" Then
MsgBox ("You must select a database to connect to.")
End If
strMsg = "Are you sure you want to link the database tables to the tables in the database:" & Chr(10) & Chr(10) & FileDialog.FileName
resval = MsgBox(strMsg, vbYesNo)
If resval = 7 Then
Exit Sub
End If

Dim tbl As dao.TableDef
Dim dbs As dao.Database
Dim X As Integer
X = 1
Set dbs = CurrentDb

Do While X < dbs.TableDefs.Count
Set tbl = dbs.TableDefs(X)
If tbl.Connect > &quot;&quot; Then
tbl.Connect = &quot;;DATABASE=&quot; & FileDialog.FileName
tbl.RefreshLink
End If
X = X + 1
Loop
MsgBox (&quot;Table linking process is complete.&quot;)


I execute this if I hit an Err.Number = 3024 condition when accessing my first table.

Hope it helps.

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top