A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Change one table link by vba



 
 
Thread Tools Display Modes
  #1  
Old December 18th, 2009, 10:27 AM posted to microsoft.public.access
K[_4_]
external usenet poster
 
Posts: 25
Default Change one table link by vba

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
  #2  
Old December 18th, 2009, 11:21 AM posted to microsoft.public.access
Stefan Hoffmann
external usenet poster
 
Posts: 991
Default Change one table link by vba

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 --
 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:53 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.