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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

linking tables from another database 1

Status
Not open for further replies.

MBall2003

Programmer
May 30, 2003
61
0
0
US
i am currently working on a billing database. i need to pull out two tables of information from a purchase order database on a user event. it would be nice if i could link the tables from my d-base to the PO (purchase order) d-base but i cant because the user isn't always going to be on the network , so my d-base has to be a stand alone db. is there anyway that i can , on the user event, grab the data i need from the PO d-base ( open a link to those two tables), query out the data, then unlink the two tables?

any help would be appreciated thanks

mball
 
Sure can. Try this code.

Dim db As DAO.Database
Dim TD As DAO.TableDef
Set db = CurrentDb

Set TD = db.CreateTableDef("tblNameToCallTable1")
TD.Connect = ";Database=" & "G:\... path to database ...\DataBaseName.mdb;"
TD.SourceTableName = "tblNameOfSourceTable1"
db.TableDefs.Append TD

Set TD = db.CreateTableDef("tblNameToCallTable2")
TD.Connect = ";Database=" & "G:\... path to database ...\DataBaseName.mdb;"
TD.SourceTableName = "tblNameOfSourceTable2"
db.TableDefs.Append TD

'code to query the data and manipulate the results

Set TD = MyDB.TableDefs("tblNameToCallTable1")
db.TableDefs.Delete "tblNameToCallTable1"

Set TD = MyDB.TableDefs("tblNameToCallTable2")
db.TableDefs.Delete "tblNameToCallTable2"

db.Close

Update this code with correct table names and path to the source database location and names and this code will link the tables and after you code runs on the data needed it will remove the links to the source database tables.

Post back with questions.

Bob Scriver
Want the best answers? See FAQ181-2886
Nobody believes the official spokesman... but everybody trusts an unidentified source.
Author, Bagdad Bob???

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top