Linking Tables

RangerTen

Rangers Lead The Way!
Local time
Today, 14:08
Joined
Jun 30, 2002
Messages
42
Is there a quick EASY way to link tables to the current application directory...

I have a database that is linked to tables in another directory. Coding is easy in access if the tables (linked tables) are in a permanent, static directory...in fact, you can even use the table linking tool to do all the work for you. However, I want to use a relative directory and don't know how and where to code the relative location. Can anyone help me here. I'm a bit lost.

Thanks for the help!

Pete
 
You use the DoCmd.TransferDatabase command to link tables. (I know, not the most intuitively-named command for that purpose.)

Here's an example of the command:
DoCmd.TransferDatabase acLink, "Microsoft Access", _
"F:\db2.mdb", _
acTable, "tblAddress", "tblAddressNew"


The important part for you is the third parameter where I have "F:\db2.mdb". That's where you tell Access where the database containing the information you want is located.

If you know the current path of your database file, which you can determine by using the CurrentProject.Path property, you can change the command to this:
DoCmd.TransferDatabase acLink, "Microsoft Access", _
CurrentProject.Path & "\db2.mdb", _
acTable, "tblAddress", "tblAddressNew"
 
Thanks, dcx693 - again this week. My urgent query today is very similar, but I think you have answered it here for me without any need for me to post it. Many thanks and cheers.
 
I've been trying variations, dcx693, of your code, but so far Access won't oblige. My DoCmd line is this

DoCmd.TransferDatabase acLink, "Microsoft Access", "T:\www.bemrosebooth.com\OnLine_Marketing\Link Building\Link Survey databases\ForNewLinks.mdb", acTable, "tblTableEdited"

I'd be grateful if you'd tell me if you see a fault there. Unfortunately, I have to live with the spaces in some folder names. Management won't budge on that score.
Cheers
 

Users who are viewing this thread

Back
Top Bottom