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

Linkled Table Exist?

Status
Not open for further replies.

hedidit

Technical User
Jul 21, 2005
142
GB
Can someone show me any example code of how to check whether a table is currently linked into my database?

Example: I'm in database A, database B has a table called Archive... I want to know whether my current database (database A) is linked to table arbice in database b...

Cheers
 
You should be able to use the ForeignName field of the MSysObjects system table:

[tt]TableName=DlookUp("Name","MSysObjects","ForeignName='Archive'")[/tt]

If you need more, it may be best to use TableDefs.
 
In database A, if the query

SELECT *
FROM MSysObjects
WHERE Type=6
AND Name='Archive';

returns a row, you have a linked table (denoted by type 6) called 'Archive' in that db. That's not to say it's linked to the table in database B, but you can look at the Connect field returned as part of this query to see the connection string, which will tell you the db the linjked table is linked to.

[pc2]
 
Thanks for the replies, I'll have a go with both now... I'm merely trying to tell whether the table is linked... not so bothered about whether it's from database b...

cheers again
 
mp9, it is possible that the Name will be different from the ForeignName.
 
Yes it is different... in database A it's called Archive, in database B it's called TblArchive...

 
I guess that's what happends when I make posts based on an unreliable memory!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top