Results 1 to 5 of 5

Thread: extracting tables from database and variables.

  1. #1

    Thread Starter
    Lively Member jonvantuyl's Avatar
    Join Date
    Nov 2000
    Location
    Michigan
    Posts
    75

    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

  2. #2
    PowerPoster Beacon's Avatar
    Join Date
    Jan 2001
    Location
    Pub Floor
    Posts
    3,188
    Look at my code in Phuties thread a few posts down from this one!!

    b

  3. #3

    Thread Starter
    Lively Member jonvantuyl's Avatar
    Join Date
    Nov 2000
    Location
    Michigan
    Posts
    75

    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

  4. #4
    PowerPoster Beacon's Avatar
    Join Date
    Jan 2001
    Location
    Pub Floor
    Posts
    3,188
    VB Code:
    1. For Each tbl In cat.Tables
    2. If InStr(UCase(tbl.Name), "MSYS") = 0 Then
    3.                
    4.                  If UCase(tbl.Name) = UCase(sTableName) Then
    5.                         combo1.additem stablename
    6.                         Exit For
    7.                   End If
    8.  
    9.         End If
    10. Next tbl

  5. #5

    Thread Starter
    Lively Member jonvantuyl's Avatar
    Join Date
    Nov 2000
    Location
    Michigan
    Posts
    75

    thx

    ok thanks much

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width