Link to home
Start Free TrialLog in
Avatar of hidrau
hidrauFlag for Brazil

asked on

is there any way to created a linked table from the same directory and don't have a path in the linked?

Hello guys

I have a database A and Database B in access

I created a linked table in Database B from Database A

The problem is that this linked table kept the path of my database and when I install the program in a computer that will be with another unit, that isn't C:, I have this linked table broken.

Both Databases are in the same fold, this way, I don't need the path.

Is there any way to create this linked table without the path, so that it can get the local fold where the database is?

thanks
ASKER CERTIFIED SOLUTION
Avatar of borki
borki
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ooh, I forget, if you use the above code, you need to set a code reference in the Tools > Reference menu for the 'Microsoft ADO Ext <your version>"

Good luck
Avatar of hidrau

ASKER

I use 2003
Yes that code should work, the reference is to be set in the Visual Basic Environment. Also, the Linked Table manager should be installed, if you want to go that way.
Avatar of hidrau

ASKER

Borki,

I don't know much on access, I use it only for a database and call all tables in delphi.

Could you give me the steps to create this function? Where ?

thanks
Avatar of Scott McDaniel (EE MVE )
borki's suggestion will work, bu in most cases if you're going to maintain your application in Access, you're better off using DAO methods to do this. ADOX will do the job, but Access is much more closely coupled with DAO.

If you wish to relink tables that will be in a database in the same folder as your "Frontend" (i.e. the file with all the Forms, Reports, etc), you can use code like you'll find at http://www.fabalou.com/Access/Modules/refreshtables.asp to do this. It's about as straight forward as it comes, and will work with any version of Access.

Note this would relink ALL tables in the database; if you only wish to link some of those tables, you'll have to modify this somewhat.

To use this, copy the below code into a standard VBA module, then call it like this:

RelinkTables CurrentProject.Path & "\YourBackendDatabase.mdb"


'RelinkTables...Just as the name suggests pass a path to a database to this sub
'eg RelinkTables("c:\windows\test.mdb")
'and it will go through all the tables in your
'database and link them to the new location
'Written by John Hawkins 20/9/99 www.fabalou.com
Public Sub RelinkTables(NewPathname As String)
    Dim Dbs As Database
    Dim Tdf As TableDef
    Dim Tdfs As TableDefs
    Set Dbs = CurrentDb
    Set Tdfs = Dbs.TableDefs
'Loop through the tables collection
       For Each Tdf In Tdfs
        If Tdf.SourceTableName <> "" Then 'If the table source is other than a base table
            Tdf.Connect = ";DATABASE=" & NewPathname 'Set the new source
            Tdf.RefreshLink 'Refresh the link
        End If
    Next 'Goto next table
End Sub 


From here: http://www.fabalou.com/Access/Modules/refreshtables.asp

Open in new window

If you got limited Access experience but control of both your user sites and there aren't too many PCs involved, I would suggest to use the Linked Table Manager, it is under Tools > Database Utilities. If it is not there, you need to install it, part of the additional wizards in the instal. options

Some help to use it can be found here:
http://office.microsoft.com/en-us/access-help/view-refresh-or-change-the-file-name-and-path-for-linked-tables-mdb-HP005187623.aspx

For me it is getting late, got to go. Good luck!

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hidrau

ASKER

thanks