473,657 Members | 2,727 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1839
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.Attribute s And dbSystemObject) = 0) And (tdf.Connect <>
vbNullString) And Not (tdf.Name Like "~*") Then
tdf.Connect = ";DATABASE=C:\M yFolder\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******@REMOV ETHIShotmail.co m> wrote in message
news:hC******** ************@wa gner.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
603
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 the commands directly from the MySQL> mode, my access works fine (see example 1 below). But when I try to access the table from PHP, I have a syntaxt problem (see example 2 below). Can anyone please type up the correct PHP syntaxt for me? The...
3
1842
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 accesses a Mysql database. The program should (ideally in my opin): Generate a form when given a database name and table. Options for display only, insert new record, and edit.
0
2012
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 in form of two tables -- let's call them "Structure" and "Orders". "Structure" keeps information on construction
0
1994
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 int(10) unsigned NOT NULL auto_increment, piece_id int(10) unsigned NOT NULL default '0',
16
2878
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 loaded into cache, the slideshow doesn't look very nice. I am not sure how/when to call the slideshow() function to make sure it starts after the preload has been completed.
0
1727
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 topic
2
2385
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 suffix ID where 1=Phd, 2= MD. To display all of these to the user, I created a form with an underlying query. The problem I am encountering is this, when we have an empty field, for example where ID="", the query returns nothing. How do i work around...
9
19139
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 ------------------------- SELECT * FROM ( Select x.event_date From x FULL OUTER JOIN y ON x.event_date = y.event_date
5
3538
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 currently getting the following error message, although this table's identity_insert is set to ON ("yes"). I'm currently re-checking all other tables to see if they would perhaps impact this. Would there be anything else I could do at this point? ...
0
8394
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8306
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8825
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7327
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6164
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1955
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1615
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.