473,473 Members | 1,842 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

linking tables to different databases

Hello-

Here is my situation. I have multiple copies of the same database on
our MS SQL server (same program, but differnet funding streams). I have
an Access 2003 front end that I link to the SQL server for ad-hoc
reports and queries. I link all the tables I need from a database (for
instance: dbo.tProvider, dbo.tParents, etc) Then I rename the tables
links in Access to just tParents, tProvider... this way I can have one
query, one report - I just update the links to the new database
whenever I need to change sources. Is there a clever way of renaming
the 'linked' table names in Access - to remove the dbo. (Im using a
painful macro right now)?

....and I have a new problem. So far this has worked out great. Because
all the databases are the same and the table ownership has been dbo.
But we recently added another copy, but the tables are
NewDBA.tProvider, NewDBA.tParent, etc (diff ownership for reason beyond
this message). So now insted of just updating the links - i have to
delete the links and create new ones - then rename to the simple form
(tProvider).

Any suggestions??

thanks,
john-

Nov 13 '05 #1
2 2048
For the first problem, you can use the following code:

Dim dbCurr As DAO.Database
Dim tdfCurr As DAO.TableDef

Set dbCurr = CurrentDb()
For Each tdfCurr In dbCurr.TableDefs
If StrComp(Left$(tdfCurr.Name, 4), "dbo_", 1) = 0 Then
tdfCurr.Name = Mid$(tdfCurr.Name, 5)
End If
Next tdfCurr

Set dbCurr = Nothing

I'm assuming that the tables are actually like dbo_tProvider, not
dbo.tProvider

For the second, you could write a loop to delete the tables if that makes it
any easier:

Dim dbCurr As DAO.Database
Dim tdfCurr As DAO.TableDef
Dim intLoop As Integer

Set dbCurr = CurrentDb()
For intLoop = (dbCurr.TableDefs.Count - 1) To 0 Step -1
Set tdfCurr = dbCurr.TableDefs(intLoop)
If Len(tdfCurr.Connect) > 0 Then
dbCurr.TableDefs.Delete tdfCurr.Name
End If
Next intLoop

Set dbCurr = Nothing

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

<jo*****@zeus.kern.org> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Hello-

Here is my situation. I have multiple copies of the same database on
our MS SQL server (same program, but differnet funding streams). I have
an Access 2003 front end that I link to the SQL server for ad-hoc
reports and queries. I link all the tables I need from a database (for
instance: dbo.tProvider, dbo.tParents, etc) Then I rename the tables
links in Access to just tParents, tProvider... this way I can have one
query, one report - I just update the links to the new database
whenever I need to change sources. Is there a clever way of renaming
the 'linked' table names in Access - to remove the dbo. (Im using a
painful macro right now)?

...and I have a new problem. So far this has worked out great. Because
all the databases are the same and the table ownership has been dbo.
But we recently added another copy, but the tables are
NewDBA.tProvider, NewDBA.tParent, etc (diff ownership for reason beyond
this message). So now insted of just updating the links - i have to
delete the links and create new ones - then rename to the simple form
(tProvider).

Any suggestions??

thanks,
john-

Nov 13 '05 #2
Wow - this worked perfect.
I guess I have a ton of reading to do, really need to study up on
TableDefs.
Thank you for the starting place.

john-

Nov 13 '05 #3

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...
4
by: Konstantinos | last post by:
Asking for advise on the following. Suppose you want to build a database for handling some of your personal collections say for instance, your music collection, and your pictures collection. ...
1
by: Daveyk0 | last post by:
Hello there, I have a front end database that I have recently made very many changes to to allow off-line use. I keep copies of the databases on my hard drive and link to them rather than the...
2
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...
10
by: Jennifer Carr | last post by:
I have an Access 2003 application that is split into two .mdb files for the interfaces and data. This app is distributed on a CD to be used on computers that have no internet access. When someone...
6
by: robertmeyer1 | last post by:
Hi, There are several databases that have the same tables, with different reocrds. I need to be able to combine them all into 1 in an easy manner/best. How can I do this and are there potential...
1
by: lochmant | last post by:
I have a series of about 10 test databases with about 34 linked table each. I need to create an Access 2003 database front end for each of these. I am currently trying to write a script that will...
7
by: Salad | last post by:
I am converting an application from A97 to A2003. I have 2 tables created by another application as a Foxpro.dbf. The table has no index. The connect string in A97 is FoxPro...
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,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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,...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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...

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.