PC Review


Reply
Thread Tools Rate Thread

Change one table link by vba

 
 
K
Guest
Posts: n/a
 
      18th Dec 2009
Hi all, I got macro below which changes the link of all linked tables
in access. How can I ammend it to change only one table link with the
name "Summary". Please can any friend can help

Public Sub RelinkTables()
Dim Dbs As Database
Dim Tdf As TableDef
Dim Tdfs As TableDefs
Set Dbs = CurrentDb
Set Tdfs = Dbs.TableDefs
'Loop through the tables collection
For Each Tdf In Tdfs
If Tdf.SourceTableName <> "" Then 'If the table source is other than a
base table
Tdf.Connect = ";DATABASE=\\Home\Document\Record.mdb"
Tdf.RefreshLink 'Refresh the link
End If
Next 'Goto next table
End Sub
 
Reply With Quote
 
 
 
 
Stefan Hoffmann
Guest
Posts: n/a
 
      18th Dec 2009
hi,

On 18.12.2009 10:27, K wrote:
> Hi all, I got macro below which changes the link of all linked tables
> in access. How can I ammend it to change only one table link with the
> name "Summary".

Instead of the loop request that table from the TableDefs collection.

Public Sub RelinkSummaryTable()

'On Local Error Resume Next

Dim db As DAO.Database
Dim tdf As DAO.TableDef

Set db = CurrentDb
Set tdf = db.TableDefs.Item("Summary")
tdf.Connect = ";DATABASE=\\Home\Document\Record.mdb"
tdf.RefreshLink
Set tdf = Nothing
Set db = Nothing

End Sub



mfG
--> stefan <--
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change Link table Lior Montia Microsoft Access 1 28th Mar 2007 11:59 AM
Change link in pivot table csimon Microsoft Excel Worksheet Functions 2 8th May 2006 04:28 PM
Need Interactive Button to link to Table change vice Page Change =?Utf-8?B?QWx3YXlzTWFyaW5l?= Microsoft Frontpage 1 9th Mar 2006 10:22 AM
Change Link Table to Local Table With VBA =?Utf-8?B?cm1jb21wdXRl?= Microsoft Access External Data 2 28th Nov 2005 08:59 AM
change table link properties =?Utf-8?B?TVNTUUxTZXJ2ZXJEZXZlbG9wZXI=?= Microsoft Access 1 26th Jan 2005 01:48 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:52 PM.