469,906 Members | 2,188 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,906 developers. It's quick & easy.

Linking / attaching tables in VBA

I am familiar with VBA and the manual method of attaching/linking
external data tables (File, Get External Data etc). I am also
familiar with opening tables which exist in the current Access file,
in VBA and reading / writing records.

What I want to do is attach external data tables in VBA ... can anyone
please help? I suppose I could do it with SendKeys, but that's
clumsy.

=============================
Rob Davis, Telford Shropshire
LUD297W CX500A 1981
remove * for email reply
=============================
Nov 12 '05 #1
3 15269
See Allen Browne

http://users.bigpond.net.au/abrowne1/ser-13.html

Phil
"Rob Davis" <el****@deletethis.blueyonder.co.uk> wrote in message
news:3f**************@news.blueyonder.co.uk...
I am familiar with VBA and the manual method of attaching/linking
external data tables (File, Get External Data etc). I am also
familiar with opening tables which exist in the current Access file,
in VBA and reading / writing records.

What I want to do is attach external data tables in VBA ... can anyone
please help? I suppose I could do it with SendKeys, but that's
clumsy.

=============================
Rob Davis, Telford Shropshire
LUD297W CX500A 1981
remove * for email reply
=============================

Nov 12 '05 #2
Baz
Rob,

Here's a snippet of code which might help. tdf and tdfLink are DAO tabledef
objects. dbLink is the target database, dbSel is this database. strPath
contains the path of the target mdb.

'Enumerate the tables in the target database, in order to link to them
For Each tdf In dbLink.TableDefs
'Only interested in non-system tables, which aren't linked
If ((tdf.Attributes And dbSystemObject) = 0) And ((Len(tdf.Connect))
= 0) Then
'Create a new table def, named as per the target table
Set tdfLink = dbSel.CreateTableDef(tdf.name)
'Identify the target table for the link
tdfLink.SourceTableName = tdf.name
'Identify its path
tdfLink.Connect = ";DATABASE=" & strPath
'And add it to this database's tables
dbSel.TableDefs.Append tdfLink
End If
Next

HTH

Baz

"Rob Davis" <el****@deletethis.blueyonder.co.uk> wrote in message
news:3f**************@news.blueyonder.co.uk...
I am familiar with VBA and the manual method of attaching/linking
external data tables (File, Get External Data etc). I am also
familiar with opening tables which exist in the current Access file,
in VBA and reading / writing records.

What I want to do is attach external data tables in VBA ... can anyone
please help? I suppose I could do it with SendKeys, but that's
clumsy.

=============================
Rob Davis, Telford Shropshire
LUD297W CX500A 1981
remove * for email reply
=============================

Nov 12 '05 #3
Thanks to the pair of you, I'll try these.
=============================
Rob Davis, Telford Shropshire
LUD297W CX500A 1981
remove * for email reply
=============================
Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by John South | last post: by
5 posts views Thread by Christoph Sticksel | last post: by
1 post views Thread by deiopajw | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.