re-link table in code

  • Thread starter Thread starter Song Su
  • Start date Start date
S

Song Su

access 2003

I have a form with a textbox. I what that box to display current linking
path and allow users to change to new location. after user hit a button, i
want that button to re-link to users' new location. if successful, give a
message. otherwise, stay with current link and give message.

I searched and found Dev Ashish's site:
http://www.mvps.org/access/tables/tbl0009.htm

but i don't know if that code suiteable for me (display current link, allow
user to change). if it is, how to use it. if it is not, how to modify.

someone can help, please?

Thanks

Song
 
I'm afraid you have to be a little more specific than that.

To use Dev's code, you call the function fRefreshLinks. (Make sure you've
also included all of the code from
http://www.mvps.org/access/api/api0001.htm, as it says to on the page you
cited).

Once you've got it running, what doesn't the code do that you want it to do?
What does it do that you don't want it to do?
 
Hi, Douglas,

Let me try to make it more specific. I split my app to frontend and backend.

I have a textbox on a form called txtLoc
and I want my current backend link location
f:\apps\ics\data\icsdata.mdb shown in txtLoc textbox (how to do that?)

then, if user perfer, user can type new location of backend file in txtLoc.
When user click OK, I want my application to link to the new location that
user typed. (how to do that?)

next time user opens the form, the txtLoc will show the new location.

Thanks.

- Song
 
Realistically, knowing what the current backend link is can be non-trivival,
since each table can be linked to a different database.

However, if you know that all of your linked tables are pointing to the same
back-end, you can use a function like:

Function BackendDatabase() As String
Dim strConnect As String

BackendDatabase = Mid(CurrentDb.TableDefs("NameOfTable"), 11)

End Function

(replace NameOfTable with the name of a linked table in your database)

Running Dev's code will prompt to the user to select the location of the new
back-end database through the standard Windows FileOpen dialog and relink
the tables for you.
 
Thank you, David. I imported your utilities and it seems work with a few
error message I guess because of my Access 2003.

Added "11.0" in LinkedTableManager click Case "9.0", "10.0", "11.0"

- Song
 
Back
Top