How to link to the tables in backend from frontend

dhlao

Registered User.
Local time
Today, 15:21
Joined
Dec 23, 2014
Messages
37
I've found some code on the web, like below
Code:
Dim dbs As DAO.Database
Dim tdf As DAO.TableDef
Dim strConnect As String
Set dbs = CurrentDb
Set tdf = dbs.TableDefs("target_table")
tdf.Connect = ";DATABASE=" & thePathToTheAccdb
tdf.RefreshLink
But I always got the error "Item not found in this collection". And it's cause by the line "Set tdf = dbs.TableDefs("target_table")"

Of course. The table "target_table" is in the backend thePathToTheAccdb file. Not "CurrentDb".

Is there a way to link a table which is reside in another accdb file ?
 
You only pulled part of the code. "target_table" is shorthand by whoever wrote what you snagged, telling you to replace it with the name of the table you want to link.

CurrentDb is referenced because ALL tabledefs are stored locally, even for linked tables.

Basically, what you're doing is called a DSNless connection.
 

Users who are viewing this thread

Back
Top Bottom