473,386 Members | 1,647 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 15497
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: John South | last post by:
I have an Access 2000 front end that I wish to work with a SQL Server 2000 database by means of Linked tables. Do I have to use an ODBC connection to SQL Server? It seems to be the only option...
0
by: gasturbtec | last post by:
please help im new at access programming and i just got this project dropped in my lap because the old programmer quit. i've been doing ok so far but now i need to add code to an existing database...
18
by: Mark P | last post by:
I have a bit of vb code that uses Tables.Append to programatically link tables from Oracle and DB2 datasources. The problem I am having on some client machines is that the link will take anywhere...
5
by: Christoph Sticksel | last post by:
Hi, I'm having problems with attaching two tables stored in an SQL Server 2000 to an Access 97 database. It worked well for all other tables except those two. This is what I did: Choose the...
2
by: kai | last post by:
Hi, All I used to link a SQL Server 2000 table through ODBC in Access 2003 using Wizard, now because the security requirement, I want to do the same job using code. I tried hard, but not...
2
by: Simon Verona | last post by:
I have a combobox that is contained within a user control. Whilst the application is running, I'm attaching the combobox to a new dataset. The problem I'm getting is that the combobox doesn't...
1
by: deiopajw | last post by:
I have a Back end database on a network drive. The copies of the front end are located on individual pc's (in their C drive). The problem arises when a laptop user naturally hooks up to the...
2
by: pssraju | last post by:
Hi, At present application was built on solaris 9 using sun studio 9 (Sun C++ 5.6) & rouguewave sorce pro 5. We are planning to port the same application onto SuSE Linux 9.5.0 using GCC 3.3.3 & RW...
3
by: ARC | last post by:
I'm having trouble here with Access 2007 and connecting to a different database. The code below works great IF the previous back-end database connection is still present and you are trying to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.