|
-
Jun 4th, 2002, 09:59 PM
#1
Thread Starter
Lively Member
extracting tables from database and variables.
when using this code below that i found on this board, i want it to display the tables that are inside the database and add these to a combo box, which it does but it also adds these to the combo box:
MSysAccessObjects
MSysAccessXML
MSysACEs
MSysObjects
MSysQueries
MSysRelationships
is there any way to make it so that these aren't shown in the database?
Access xp and vb 6 sp5.
Code:
'Add a reference to Microsoft ADO Ext. X.X For DLL And Security
'Add a reference to Microsoft ActiveX Data Objects X.X Library
Option Explicit
Private cat As ADOX.Catalog
Private tbl As ADOX.Table
Private cnn As New ADODB.Connection
Private Sub Form_Load()
Set cat = New ADOX.Catalog
Set tbl = New ADOX.Table
'setup db connection
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Jonathon Vantuyl\Desktop\Roster Manager\jv football.mdb"
Set cat.ActiveConnection = cnn
'loop through all tables, and all fields in each table.
For Each tbl In cat.Tables
cmbRecordSource.AddItem tbl.Name
Next tbl
'close the connection
cnn.Close
Set cnn = Nothing
End Sub
Also:
is it possible to make it run of from a global variable. i attempt just like replasing the location with the variable name and then it says it cant find the file (but adds the location extension, so its like.......C:\Documents and Settings\Jonathon Vantuyl\Desktop\Roster Manager\database). database is the variables name.
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Jonathon Vantuyl\Desktop\Roster Manager\jv football.mdb"
One More:
once the database is selected, and then the table, how do i add the colums (fields or whatever they are called) to a list box?
thanks much
-
Jun 4th, 2002, 10:01 PM
#2
PowerPoster
Look at my code in Phuties thread a few posts down from this one!!
b
-
Jun 4th, 2002, 10:14 PM
#3
Thread Starter
Lively Member
ok
thanks but i am having trouble to get it work correctly because i dont need to check if it exist but i know that all the MSYS exist. i just dont want them to show up in the combo box. so if you could provide some code or explain it would help alot. thanks
-
Jun 5th, 2002, 12:13 AM
#4
PowerPoster
VB Code:
For Each tbl In cat.Tables
If InStr(UCase(tbl.Name), "MSYS") = 0 Then
If UCase(tbl.Name) = UCase(sTableName) Then
combo1.additem stablename
Exit For
End If
End If
Next tbl
-
Jun 5th, 2002, 10:26 AM
#5
Thread Starter
Lively Member
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
|