473,795 Members | 3,041 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Linking Tables in Access

Hi Everyone,

Just wonderring if it is possible to link tables in access using 'relative'
terminology rather than 'absolute' ?

For example the path would become '\Sourcefile\My Pets.mdb' rather than
'C:\folders\Sou rcefile\MyPets. mdb'.

The beauty of this type of referencing (if possible) is that I would be able
to have two copies, a development copy and a live copy and not have to worry
about the links (provided I maintained the same lower folder structure).

If I have explained poorly or you want more info please feel free to ask.
Equally if you know the answer to the question of whether it is possible I
would also appreciate it.

Thanks,

John
Nov 13 '05 #1
4 4745
"John Ortt" <jo******@noema ilsuppliedasdon twantspam.com> wrote in message
news:43******** **@glkas0286.gr eenlnk.net...
Hi Everyone,

Just wonderring if it is possible to link tables in access using
'relative' terminology rather than 'absolute' ?

For example the path would become '\Sourcefile\My Pets.mdb' rather than
'C:\folders\Sou rcefile\MyPets. mdb'.

Do you mean in code? You could always set a string variable to contain the
path - is this what you're getting at?

Regards,
Keith.
www.keithwilby.com
Nov 13 '05 #2

"Keith" <ke*********@ba eAWAYWITHITsyst ems.com> wrote in message
news:43******** **@glkas0286.gr eenlnk.net...
"John Ortt" <jo******@noema ilsuppliedasdon twantspam.com> wrote in message
news:43******** **@glkas0286.gr eenlnk.net...
Hi Everyone,

Just wonderring if it is possible to link tables in access using
'relative' terminology rather than 'absolute' ?

For example the path would become '\Sourcefile\My Pets.mdb' rather than
'C:\folders\Sou rcefile\MyPets. mdb'.

Do you mean in code? You could always set a string variable to contain
the path - is this what you're getting at?

Not quite Keith, I found the code at the bottom of the post previously and
it has been extremely useful, particularly for removing mapped drive letter
and replacing them with server names which ensures people with different
mappings can still access the files.
What I am wonderring is if I can use a partial path (ie. relative to the
folder location of the database in use).
I ask this based on the ability to do it with html. For instance you can
either say the full path for the location of an image or you can give it
relative to the current folder.

Hope that makes sense,

John.
Option Compare Database
Option Explicit

Function ChangeLinksCode ()
Dim Db As DAO.Database
Dim tbl As DAO.TableDef
Dim oldBE As String
Dim newBE As String
Dim i As Integer
Dim tbln As String
Dim lnk As String
Dim Check As String

Set Db = CurrentDb() 'Announces that the code works on this database
oldBE = "P:\"
newBE = "\\Maasams01\Pr ojects\"

'The two lines above give the location of the old file path (oldBE)
'and then the desired location of the new file path (newBE)

'The following code loops from i=0 (Line 1) until the last line of the table
definitions (db.TableDefs.C ount - 1)
'It checks that the link is to a database (Left(lnk, 9) = ";DATABASE" )
'and if so replaces all instances of the oldpath with the new one

For i = 0 To Db.TableDefs.Co unt - 1
tbln = Db.TableDefs(i) .Name
Set tbl = Db.TableDefs(tb ln)
lnk = tbl.Connect
Check = tbl.Connect
If Left(lnk, 9) = ";DATABASE" Then
lnk = Replace(lnk, oldBE, newBE)
If lnk <> Check Then
tbl.Connect = ""
tbl.Connect = lnk
tbl.RefreshLink
End If
End If
Next

'The next section of the code repeats that above but for non database files
(i.e. text and excel files)

oldBE = "P:\"
newBE = "\\Maasams01\Pr ojects\"

For i = 0 To Db.TableDefs.Co unt - 1
tbln = Db.TableDefs(i) .Name
Set tbl = Db.TableDefs(tb ln)
lnk = tbl.Connect
Check = tbl.Connect
If Left(lnk, 9) <> ";DATABASE" Then
lnk = Replace(lnk, oldBE, newBE)
If lnk <> Check Then
tbl.Connect = ""
tbl.Connect = lnk
tbl.RefreshLink
End If
End If
Next

End Function
Function Replace(ByVal Valuein As String, ByVal WhatToReplace As
String, ByVal Replacevalue As String) As String
Dim Temp As String, P As Long
Temp = Valuein
P = InStr(Temp, WhatToReplace)
Do While P > 0
Temp = Left(Temp, P - 1) & Replacevalue & Mid(Temp, P +
Len(WhatToRepla ce))
P = InStr(P + Len(Replacevalu e), Temp, WhatToReplace, 1)
Loop
Replace = Temp
End Function
Nov 13 '05 #3
"John Ortt" <jo******@noema ilsuppliedasdon twantspam.com> wrote in message
news:43******** **@glkas0286.gr eenlnk.net...

"Keith" <ke*********@ba eAWAYWITHITsyst ems.com> wrote in message
news:43******** **@glkas0286.gr eenlnk.net...
"John Ortt" <jo******@noema ilsuppliedasdon twantspam.com> wrote in message
news:43******** **@glkas0286.gr eenlnk.net...
Hi Everyone,

Just wonderring if it is possible to link tables in access using
'relative' terminology rather than 'absolute' ?

For example the path would become '\Sourcefile\My Pets.mdb' rather than
'C:\folders\Sou rcefile\MyPets. mdb'.

Do you mean in code? You could always set a string variable to contain
the path - is this what you're getting at?

Not quite Keith, I found the code at the bottom of the post previously
and it has been extremely useful, particularly for removing mapped drive
letter and replacing them with server names which ensures people with
different mappings can still access the files.
What I am wonderring is if I can use a partial path (ie. relative to the
folder location of the database in use).
I ask this based on the ability to do it with html. For instance you can
either say the full path for the location of an image or you can give it
relative to the current folder.

Hope that makes sense,

Hmm ... yes I think I know what you mean but I've never heard of any method
from within VBA but I'm sure someone will jump in and correct me ...
Nov 13 '05 #4

"Keith" <ke*********@ba eAWAYWITHITsyst ems.com> wrote in message
news:43******** **@glkas0286.gr eenlnk.net...
"John Ortt" <jo******@noema ilsuppliedasdon twantspam.com> wrote in message
news:43******** **@glkas0286.gr eenlnk.net...

"Keith" <ke*********@ba eAWAYWITHITsyst ems.com> wrote in message
news:43******** **@glkas0286.gr eenlnk.net...
"John Ortt" <jo******@noema ilsuppliedasdon twantspam.com> wrote in message news:43******** **@glkas0286.gr eenlnk.net...
Hi Everyone,

Just wonderring if it is possible to link tables in access using
'relative' terminology rather than 'absolute' ?

For example the path would become '\Sourcefile\My Pets.mdb' rather than 'C:\folders\Sou rcefile\MyPets. mdb'.

Do you mean in code? You could always set a string variable to contain
the path - is this what you're getting at?
Not quite Keith, I found the code at the bottom of the post previously
and it has been extremely useful, particularly for removing mapped drive
letter and replacing them with server names which ensures people with
different mappings can still access the files.
What I am wonderring is if I can use a partial path (ie. relative to the
folder location of the database in use).
I ask this based on the ability to do it with html. For instance you can either say the full path for the location of an image or you can give it
relative to the current folder.

Hope that makes sense,

Hmm ... yes I think I know what you mean but I've never heard of any

method from within VBA but I'm sure someone will jump in and correct me ...

I don't think Access allows relative paths. So it would not be possible to
move the front and back end files and have them still linked.

However, you can get the current folder in code, and add the relative path
to create the full path you need and then link the tables in code. If you
do this when the front-end is opened, the user will not know any difference
between having the tables linked using a relative path.

David
Nov 13 '05 #5

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

Similar topics

3
4396
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
4505
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?
14
2962
by: diskoduro | last post by:
Hi!! Years ago I built a database to control the production of a little factory. The users wanted to work in a Windows Net workgroup so I created an mdb with all the tables and data an after that every user had his own mde linked to the main mdb. Year by year, progressively the number of records has been growing and the speed of the application has decreased strongly, because of the grrrreat number of records stored.
0
2248
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...
18
3091
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 from 1 to 3 minutes to link the table. When I manually link the tables,through Access, it takes no time at all. Note that only certain client have the problem, and the problem will sometimes go away. These clients will usually get an ODBC Call...
5
3781
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 data source from the ODBC dialog, choose the database on SQL Server login, select all tables in the SQL Server database. All tables were attached except the two, it says something like "database module can't find 'dbo_<tablename>'".
2
4141
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...
3
3164
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
7
3063
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 2.0;HDR=NO;IMEX=2;DATABASE=C:\Test It's really easy to connect to those tables in A97. I'm having difficulties in A2003. I'm trying to follow the instructions in http://support.microsoft.com/kb/824264/.
0
9672
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
9519
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
10438
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...
1
10164
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10001
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
9042
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
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3727
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
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.