SteveL13
asked on
How add linked tables to the back-end file of a split database via VBA code
I'm trying to find a way to add linked tables to the back-end file of a split database via VBA code.
Does anyone know of code that will do this? I want to allow the user to browse to the external Access database file and select the two files (there will always be two), and have them appear as linked files in the working F/E file.
Does anyone know of code that will do this? I want to allow the user to browse to the external Access database file and select the two files (there will always be two), and have them appear as linked files in the working F/E file.
That won't work. Tables linked in the backend will be visible in the backend only, not from the frontend.
If you from the frontend wish access to other tables than those in your current backend, you must link those tables directly in the frontend.
/gustav
If you from the frontend wish access to other tables than those in your current backend, you must link those tables directly in the frontend.
/gustav
ASKER
Gustav... you are correct. I'm ok with the linked tables showing up in the front-end file.
Rey, I've copied your code. The onclick event works fine except I had to change
DoCmd.TransferDatabase acLink, "Microsoft Access", dbFile, acTable, <TableName1>,<TableName1>
and
DoCmd.TransferDatabase acLink, "Microsoft Access", dbFile, acTable, <TableName2>,<TableName2>
to
DoCmd.TransferDatabase acLink, "Microsoft Access", dbFile, acTable, "TableName1","TableName1"
and
DoCmd.TransferDatabase acLink, "Microsoft Access", dbFile, acTable, "TableName2","TableName2"
But I don't know what to replace the "TableName1","TableName1" and "TableName2","TableName2" with.
I am able to navigate to the accdb file I want to get to and select it. But after I've selected it I get...
which I understand but I don't know how to get the real table names in place.
Rey, I've copied your code. The onclick event works fine except I had to change
DoCmd.TransferDatabase acLink, "Microsoft Access", dbFile, acTable, <TableName1>,<TableName1>
and
DoCmd.TransferDatabase acLink, "Microsoft Access", dbFile, acTable, <TableName2>,<TableName2>
to
DoCmd.TransferDatabase acLink, "Microsoft Access", dbFile, acTable, "TableName1","TableName1"
and
DoCmd.TransferDatabase acLink, "Microsoft Access", dbFile, acTable, "TableName2","TableName2"
But I don't know what to replace the "TableName1","TableName1" and "TableName2","TableName2" with.
I am able to navigate to the accdb file I want to get to and select it. But after I've selected it I get...
which I understand but I don't know how to get the real table names in place.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes. Will always only have two.
ASKER
Absolute perfect! Thank you very much!!!
docmd.TransferDatabase acLink .........
instead
here is a function to browse for the accdb
Open in new window
in the click event of a button
Open in new window