473,796 Members | 2,707 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

programatically linking tables

Tym
OK - daft question of the day time...

If I have database A which contains all the live data, and Database B
which contains linked tables to those is A (i.e. a front end) is there
a way of seeing if any tables have been addedd to A and if so,
programatically creating a linked table to the new tables?

Failing this, can I programatically delete all linked tables, then
link re-link to every table which appears in tableA?

Does that make sense??

Tym
Nov 12 '05 #1
3 11821
To add a table to the current database, try modifying this to meet your
requirements. Look through the help file for more info

Dim tbl As TableDef
Dim db As Database

Set db = CurrentDb
Set tbl = db.CreateTableD ef(tblName, dbAttachedTable , SourceName,
ConnectionStrin g)
db.TableDefs.Ap pend tbl

To remove one

db.TableDefs.De lete tblName

Mike Storr
www.veraccess.com
"Tym" <no*****@ictis. net> wrote in message
news:40******** *****@169.100.1 00.5...
OK - daft question of the day time...

If I have database A which contains all the live data, and Database B
which contains linked tables to those is A (i.e. a front end) is there
a way of seeing if any tables have been addedd to A and if so,
programatically creating a linked table to the new tables?

Failing this, can I programatically delete all linked tables, then
link re-link to every table which appears in tableA?

Does that make sense??

Tym



Nov 12 '05 #2
DFS
Here's a non-programmatic way to see the differences:

SELECT A.Name AS TableName
FROM MSYSOBJECTS A IN 'path to back-end database A'
WHERE
A.TYPE = 1
AND LEFT(A.NAME,4) <> 'MSYS'
AND A.NAME NOT IN
(SELECT B.Name AS TableName
FROM MSYSOBJECTS B IN 'path to linked database B'
WHERE
B.TYPE = 6
AND LEFT(B.NAME,4) <> 'MSYS'
);

To return valid results, this query requires/assumes your link names in
database B match the table names in A.

You can programmaticall y link tables - investigate the Connect and
RefreshLink methods.


"Tym" <no*****@ictis. net> wrote in message
news:40******** *****@169.100.1 00.5...
OK - daft question of the day time...

If I have database A which contains all the live data, and Database B
which contains linked tables to those is A (i.e. a front end) is there
a way of seeing if any tables have been addedd to A and if so,
programatically creating a linked table to the new tables?

Failing this, can I programatically delete all linked tables, then
link re-link to every table which appears in tableA?

Does that make sense??

Tym

Nov 12 '05 #3
"Tym" <no*****@ictis. net> wrote in message
news:40******** *****@169.100.1 00.5...
OK - daft question of the day time...

If I have database A which contains all the live data, and Database B
which contains linked tables to those is A (i.e. a front end) is there
a way of seeing if any tables have been addedd to A and if so,
programatically creating a linked table to the new tables?

Failing this, can I programatically delete all linked tables, then
link re-link to every table which appears in tableA?

Does that make sense??

Tym

Why would you want to do that?
Do you think users are deleting linked tables from the front end?
Are you adding tables to the back end which you want to be automatically
included as linked tables in the front end?
Normally, if there are back end changes, then there are associated front end
changes. E.g. you add a new table called tblCustomerNote s then typically
there will be new or amended forms and reports to display this data.
Getting the front end to simply generate a new linked table for this will
generally not be enough.
However, if you need some coding ideas, these functions may help:

Public Function GetBackEndPath( ) As String

On Error GoTo Err_Handler

' Assumes there is a single back-end .mdb
Dim dbs As DAO.Database
Dim tdf As DAO.TableDef

Set dbs = CurrentDb

For Each tdf In dbs.TableDefs
If Len(tdf.Connect ) > 0 Then
GetBackEndPath = Mid$(tdf.Connec t, 11)
Exit For
End If
Next tdf

Exit_Handler:
On Error Resume Next
Set tdf = Nothing
Set dbs = Nothing
Exit Function

Err_Handler:
' No error message
Resume Exit_Handler

End Function

Public Function DeleteLinks() As Boolean

On Error GoTo Err_Handler

Dim dbs As DAO.Database
Dim lng As Long

Set dbs = CurrentDb

With dbs.TableDefs
For lng = .Count - 1 To 0 Step -1
If (.Item(lng).Att ributes And dbAttachedTable ) <> 0 Then
.Delete .Item(lng).Name
End If
Next lng
End With

DeleteLinks = True

Exit_Handler:
On Error Resume Next
Set dbs = Nothing
Exit Function

Err_Handler:
MsgBox Err.Description , vbExclamation, "Error No: " & Err.Number
Resume Exit_Handler

End Function
Public Function CreateLinks(str BEPath) As Boolean

On Error GoTo Err_Handler

Dim dbsFE As DAO.Database
Dim dbsBE As DAO.Database
Dim wksJET As DAO.Workspace
Dim strTableName As String
Dim strConnect As String
Dim tdfBE As DAO.TableDef
Dim tdfFE As DAO.TableDef

Set wksJET = DBEngine.Worksp aces(0)

Set dbsBE = wksJET.OpenData base(strBEPath)

Set dbsFE = CurrentDb

For Each tdfBE In dbsBE.TableDefs

If Left$(tdfBE.Nam e, 4) <> "MSys" And _
Len(tdfBE.Conne ct) = 0 Then

strTableName = tdfBE.Name
strConnect = ";DATABASE= " & strBEPath
Set tdfFE = dbsFE.CreateTab leDef(strTableN ame)
tdfFE.Connect = strConnect
tdfFE.SourceTab leName = strTableName
dbsFE.TableDefs .Append tdfFE
Set tdfFE = Nothing

End If

Next tdfBE

CreateLinks = True

Exit_Handler:
On Error Resume Next
Set tdfFE = Nothing
Set tdfBE = Nothing
Set dbsFE = Nothing
dbsBE.Close
Set dbsBE = Nothing
Set wksJET = Nothing
Exit Function

Err_Handler:
MsgBox Err.Description , vbExclamation, "Error No: " & Err.Number
Resume Exit_Handler

End Function
Nov 12 '05 #4

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

Similar topics

0
1672
by: CoreyMas | last post by:
Hello Everyone, I have been successful in creating a template column programatically using the examples provided in VS 2003. However I have not been able to programatically set the width of a template column programatically Here is the code that I have used so far
3
4397
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 offered in the table linking dialog. Is there a more direct connection with OLE_DB? John South Pangbourne UK
2
4506
by: Jeff Pritchard | last post by:
Some time ago I am sure I came across something that said this was possible, though it doesn't seem to work. A client wants to replace an Access back-end with SQL Server tables. We have tried linking the SQL tables to an Access back-end and then linking the linked tables in the Access back-end to the Access front-end. Doesn't work at all. Obviously, this can't be done. What is the best way to replace an Access back-end with SQL tables?
0
2249
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 that is used to connect to other databases and generate reports. below is sample code of how the database does the linking i hope i give you enough info to help me but if not let me know and i will give more. Sub txtShipDataFileSub() Dim...
2
4142
by: Matthew Wells | last post by:
Good morning... I have an Access front end that uses SQL Server linked tables. SQL Server uses Windows authentication. I have one Windows group that all Access users are a member of. I added that group to SQL Server logins and gave it public, datareader, and datawriter rights to the one database that's used. My front end is locked down, but I want to stop users from creating a new ..mdb and linking SQL Server tables through DSNs or...
2
6241
by: TheTamdino | last post by:
One of the things that is common between most genealogy databases is that they will have one screen were you log all the information for a given person and then (maybe) have a link to a source record. I'm trying to create a database where you have tables that record facts and then link those facts to a person record. For example, I'll have tables for Birth, Marriage, Military Service, Tax Records, etc. They are separate tables because...
11
4536
by: dskillingstad | last post by:
I've been struggling with this problem for some time and have tried multiple solutions with no luck. Let me start with, I'm a novice at Access and I'm not looking for someones help to design my database,just help in getting me pointed in the right direction. I have a database with 8 tables, which from what I have read, cannot be linked on a single form, and be updatable. I have created a query which includes all 8 tables, and then...
1
2192
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 network but then the link from the front end (in the C drive of the laptop) to the back end (network drive) is lost. I have to then go to the tables section of the database window of the Front End and remove the links then link them again with the Back...
3
3165
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 connect to a new location (ie: datapath variable below). However, if you remove or even rename the old database, then launch your program, the code fails on the mytable.refreshlink line with an error 3044. (Description of that error is: 'C:\pc
0
9685
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
10467
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
10244
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10021
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9061
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...
0
6802
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();...
1
4130
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2931
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.