473,385 Members | 1,402 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,385 software developers and data experts.

A simple example of reattaching one table by VBA

Can somebody provide the minimal code (DAO) to link one Access table from
an external file (A2K)?

I have seen the examples in MVPS/MS and the code seems to want to to
everything. just can't get the essential.

Is there any difference between A97 and A2K?

TIA
Jan 21 '06 #1
1 1832
The code is the same for A97 and later versions.

The basic idea is to loop through the TableDefs collection.
Skip these tables:
- no Connect string (so they are local tables),
- temp (name starting with "~"),
- system tables (names starting with MSys.)
For the others, set the Connect property, and RefreshLink.

Basic example:
Dim tdf As DAO.TableDef
For Each tdf In dbEngine(0)(0).TableDefs
If ((tdf.Attributes And dbSystemObject) = 0) And (tdf.Connect <>
vbNullString) And Not (tdf.Name Like "~*") Then
tdf.Connect = ";DATABASE=C:\MyFolder\MyFile.mdb"
tdf.RefreshLink
End If
Next

The lengthy code at the mvps site tests first to see if a reconnect is
necessary (by trying to OpenRecordset with error handling.) If it is, it
pops up the File Open dialog so the user can choose the file to connect to.
That involves an API call, and that's what most of the lengthy code is for.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Saintor" <sa******@REMOVETHIShotmail.com> wrote in message
news:hC********************@wagner.videotron.net.. .
Can somebody provide the minimal code (DAO) to link one Access table from
an external file (A2K)?

I have seen the examples in MVPS/MS and the code seems to want to to
everything. just can't get the essential.

Is there any difference between A97 and A2K?

TIA

Jan 21 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Alex Glaros | last post by:
I need help on my basic table connection syntaxt using PHP. I call the php from a web browser url_name_goes_here/test.php. The database name is tennis and the user name is tennis. If I type...
3
by: Bob | last post by:
I am sure this has been answered in over whelming detail in this group, however the search results have not turned up any thing I am interested in. I want a simple form generator in PHP that...
0
by: Leszek Dubiel | last post by:
----------------------------------------- BACKGROUND In my company (www.glass.biz) we use ERP software to compute what has to be done to do products for our customers. Main algorithm takes data...
0
by: unixman | last post by:
As usual, it is 2:00am, and I'm pulling my hair out, finally resorting to posting in the newsgroups for help. :) Simple problem, in theory. Given table "map": CREATE TABLE map ( entry_id...
16
by: Terry | last post by:
Hi, This is a newbie's question. I want to preload 4 images and only when all 4 images has been loaded into browser's cache, I want to start a slideshow() function. If images are not completed...
0
by: pepsi | last post by:
Hello, I would suggest a simple div tag... you could assign it a id and runat server. It should work. pepsi >-----Original Message----- >Hi gang. I tried posting this under a different...
2
by: Fendi Baba | last post by:
I created a person table with various fields such as Suffix, Salutation, etc, Some of these fields may not be mandatory for example suffix. In the actual table itself, I only have a field for...
9
by: Emin | last post by:
Dear Experts, I have a fairly simple query in which adding a where clause slows things down by at least a factor of 100. The following is the slow version of the query ...
5
by: ll | last post by:
Hi, I recently detached and subsequently reattached a database, and now I've had to go back to each table and re-establish the primary keys, as well as the identity="yes" where needed. I am...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.