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

TableDefs not from CurrentDB ??? 1

Status
Not open for further replies.

notageek7

Technical User
Jan 23, 2004
54
US
Is it possible to get and use TableDefs from a database other than the CurrentDB. My application accepts a database name from the user and displays info about that database...tables and associated fields, indexed, primary keys, etc. Is there a way to use TableDefs where db is referencing a table other than the current database? Part of my problem is that I'm not really clear on what TableDefs is and or does.



Set db = CurrentDb
Set tblT = db.TableDefs(psdTableName)

For Each idx In tblT.Indexes
If idx.Primary Then
Debug.Print idx.Name, idx.Foreign, idx.Primary, idx.Unique, idx.Required
indexName = idx.Primary
Form_frmDatabaseInfo.cbxPrimaryKey.Value = idx.Name
 
A starting point
Set myObj = GetObject("\path\to\anotherdb.mdb")
Set tblT = myObj.Application.CurrentDB.TableDefs(psdTableName)
...
myObj.Application.Quit
Set myObj = Nothing

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I do this with the DBEngine's "OpenDatabase" method:

[tt]DBEngine.OpenDatabase(Name,[Options],[ReadOnly],[Connect]) As Database[/tt]

The full path goes in the Name argument. The DBEngine object reference is optional so the call looks like this:
Code:
Dim strPath As String
Dim OtherDb As DAO.Database

strPath = "\\Server\drive\databases\myDB.mdb"

Set OtherDb = OpenDatabase(strPath)

VBSlammer
redinvader3walking.gif

[sleeping]Unemployed in Houston, Texas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top