|
-
Nov 14th, 2000, 09:28 PM
#1
Thread Starter
Lively Member
How do you retrieve multiple table names from a database and display them in a listbox using dao?
-
Nov 15th, 2000, 04:34 AM
#2
Lively Member
Let's assume that you have a VB form with one simple data control named Data1, one listbox named List1, and one command button named Command1. Furthermore, I guess you're connecting to an Access database. That means that in design mode, you already entered something like "c:\...\something.mdb" in the DatabaseName property of your Data control.
So just write this code for the click event of your command button :
Private Sub Command1_Click()
Dim i As Long
Dim n As Long
n = Data1.Database.TableDefs.Count
For i = 0 To n - 1
List1.AddItem Data1.Database.TableDefs(i).Name, i
Next i
End Sub
and see what happens. I must warn you though, the Database property of the Data control is ONLY available in the proffesional and the enterprise versions of VB. Another thing : you'll notice that the first 6 tablenames retrieved are some funny names you won't recognize in your database. I'll let you figure that out for yourself (don't want to spoil all the fun :-)
Hope it will help ya.
-
Nov 15th, 2000, 03:20 PM
#3
Thread Starter
Lively Member
Yeah thanks that did the trick i just have to remove the other names by a query.
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
|