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