|
-
Feb 26th, 2000, 09:26 PM
#1
Thread Starter
Junior Member
Can you actually query a *.mdb database and retrieve the table names when the database and/or recordsource(Table) has not been set.?
-
Feb 26th, 2000, 11:41 PM
#2
Lively Member
Use the tabledefs collection to loop through the tables in a database
-
Feb 27th, 2000, 01:07 AM
#3
Thread Starter
Junior Member
Thanks, but I'm aware of that. But it can only be done as far as I know when the db or is current. I want to be able to look in a mdb file (Query it if you like) and abstract information from that *.mdb file even though I might not want to make that particulat db the current one....if you understand what i mean.
Anyone?
-
Feb 27th, 2000, 01:16 AM
#4
Guru
Are you trying to do this from MS Access VBA or thru VB? The CurrentDB property is only available thru VBA code, not VB.
In either case, if you want to get the table structure of a database, you will have to declare the objects, open the DB and enumerate thru the TableDefs collection as Steve said
-
Feb 27th, 2000, 05:00 AM
#5
Thread Starter
Junior Member
Yeah, I've finally come to the conclusion that ADO sux. Everytime I come across a potential problem with the pesky control, I find I can resolve it by using DAO!!!
Thanks for your help ppl, Clunietp I have done exactly what you mentioned and hey, it works, but not with ADO and the Data Control....
-
Feb 27th, 2000, 06:35 AM
#6
Guru
ADO is the way of the future, so you can't resist forever...
Code:
'references:
'ActiveX Data Objects 2.1
'ADO 2.1 for DDL and security
Dim tbl As ADOX.Table
Dim cn As ADODB.Connection
Dim ax As ADOX.Catalog
Set cn = New ADODB.Connection
'connect
cn.Open "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=Nwind.mdb"
Set ax = New ADOX.Catalog
ax.ActiveConnection = cn
'loop thru tables
For Each tbl In ax.Tables
Debug.Print tbl.Name & " " & tbl.Type
Next tbl
'close connection
cn.Close
Set cn = Nothing
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|