473,398 Members | 2,120 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,398 software developers and data experts.

relink to relative location txt files

I have a access 2000 database (currently running jet3.6) that has linked TXT and CSV files
I need to be able to move the location of the database often, the linked data will always be in the same place /Rawdata/ relative to the MDB file
is there anyway this can be automated to relink into the current location?


Thank you for your attention

Toby
Aug 19 '08 #1
1 4746
ADezii
8,834 Expert 8TB
  1. Create a Table named tblTablesToLink with the following 2 Fields:
    1. FileName {TEXT} - Name only of Text File, e.g. March Sales.txt
    2. TableName {TEXT} - Linked Name as you would like it to appear in DB Window
  2. Populate this Table with all the Names of the Text Files you would like to dynamically Link, as well as the Linked Names as you would like them to appear in the DB Window.
  3. Make sure to Copy these Files to the RawData Directory one level under the Directory where the Database resides.
  4. Run this code:
    Expand|Select|Wrap|Line Numbers
    1. On Error Resume Next
    2. Dim MyDB As DAO.Database
    3. Dim rstFilesToLink As DAO.Recordset
    4. Dim strPathToFiles As String
    5.  
    6. strPathToFiles = CurrentProject.Path & "\RawData\"
    7.  
    8. Set MyDB = CurrentDb
    9. Set rstFilesToLink = MyDB.OpenRecordset("tblTablesToLink", dbOpenForwardOnly)
    10.  
    11. With rstFilesToLink
    12.   Do While Not .EOF
    13.     'DELETE each existing Link, then RECREATE it!
    14.     CurrentDb.TableDefs.Delete ![TableName]       
    15.     DoCmd.TransferText acLinkDelim, , ![TableName], strPathToFiles & ![FileName], False
    16.     .MoveNext
    17.   Loop
    18. End With
    19.  
    20. rstFilesToLink.Close
    21. Set rstFilesToLink = Nothing
  5. Good Luck and Good Night!
Aug 20 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Random Person | last post by:
Does anyone know how to use VBA to relink tables between two MS Access databases? We have two databases, one with VBA code and the other with data tables. The tables are referenced by linked...
1
by: sparks | last post by:
At first I thought I could just delete the tables and import the tables. BUT my tables have relationships and I can not delete a table with relations. So that only deleted the non relational tables...
1
by: Alex VanderWoude | last post by:
I am trying to <include> some text into an XML documentation topic, but that text is stored in a file that is in a different directory than the "current" XML file. Using a relative path does not...
2
by: Joe | last post by:
Hi, can someone tell me how to set up relativ paths in VS2003 C++ ? I have some source with a tree directory structure that segments include files in various directories: #include...
2
by: Ruymán | last post by:
Hello!, is possible use relative path in access? for example use "photo\image1.jpg" instead of "c:\db\photo\image1.jpg", I try it but I cann't, but in Visual Basic if is possible. Other...
6
by: Royan | last post by:
Ok the problem is quite hard to explain, but i'll try to keep it as simple as i can. Imagine I have the following structure of my files and folders: /root/global.inc |__/files/foo.php...
2
by: BD | last post by:
Hi there. Using 8.2 on Windows. I have a situation where I have a db backup, which I want to deploy to a group of developer workstations. The target directory for the database files will be...
2
by: tobynegus | last post by:
I am trying to relink to existing linked csv and txt files, although the location may be different it is always realtive to the mdb file I have tried using the following code (GetPath returns the...
2
by: Peted | last post by:
Hi i have a circumstance where a user unzips a file, with a certain layer of directories to get to a textfile. So in any directory on the HDD they may end up with something like ...
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...
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
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...
0
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...

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.