Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

bold "Need a dynamic linked table pointer" 1

Status
Not open for further replies.

LarryDK

Programmer
Dec 23, 1999
12
US
I would like to be able to define the location of other Access databases having linked tables to the main application using a variable or somehow define it outside of Access in an ascii file which can be read in at runtime. With various users (not networked) they have different amounts of disk space available and I would like to put the main program on c: with the linked tables on d: or e:; maybe in the same directory or maybe different.

I can find no documentation about this, other than the use of the Linked Table Manager which appears to be strickly menu driven.

Any help will be appreciated.

 
You can relink the tables in code. You have to construct a connect string that includes the path name of the Access database that contains the real table. You assign this connect string to the .Connect property of the DAO TableDef object. Then you call the TableDef's .RefreshLink method.

The NorthWind database has sample code that might be helpful. Rick Sprague
 
Rick,

This is helpful. I have quite a few tables, which, I guess, I will need to reference individually, but that's fine. I could not find any example in the NorthWind database I have, which is from Access 97. There are no linked tables in that DB and I did not see anything in the modules. If you can point me to the example, that would be great, although I should be able to write something myself.

Thanks,

Larry
 
Whoops! I should have checked. The sample code isn't in NorthWind, it's in the Solutions database distributed with the Office Developer Edition. Since you're a programmer, I'm hoping you have that edition. If not, and you post your email address, I'll contact you by email. Rick Sprague
 
Here is an example...

Dim tbldef as Tabledef
Set tbldef = Currentdb.Tabledefs("MyTable")
tbldef.Connect = "DATABASE=P:\Data\Source.mdb"
tbldef.RefreshLink

What is important here is to append the standard "DATABASE=" with a valid path to the MDB. Then, you will need to use the 'RefreshLink' method to deploy the change.

Just something to add...

Due to the fact that the Linked Table Manager is very limiting, I ended up creating a Class that manages the linked tables. Using a form and the Windows API, I was able to create a very friendly Attach Table Manager that does not truncate large paths in the window like the original manager and allows the user to select the
database(s) to connect to and attach (link) them.

You may want to write an interface similar to this, because I have found such a utility to be very useful.

I realize this isn't that helpful, but the goal was to help brainstorm a bit.
 
Hey gwinn7 that's actually quite helpful--it's a great suggestion and what I need to do to take more proactive control of network db's. If you feel like posting your cls code that would be great!
 
Rick and Quinn7,

Thanks, This will get me over the hump. I think others could use these tips, also.

I'll give this a try and let you know if I have any additional problems with it.

Thanks again,

Larry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top