Results 1 to 5 of 5

Thread: List MS Access Tables in a VB ListBox

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 1999
    Posts
    239

    Post

    I have an Access Database that has a number of tables contained therein. Is there a way
    to display the tables in a VB ListBox? I am
    using a data control which binds the database
    to the project and ListBox. Thanks

  2. #2
    Junior Member
    Join Date
    Apr 1999
    Location
    Bangalore, KA, India
    Posts
    18

    Post

    I have used the following code to populate the table names in the listbix list1


    Dim db As Database
    Dim i As Long

    Set db = OpenDatabase("C:\Program Files\Microsoft Visual Studio\VB98\Biblio.mdb")

    List1.Clear

    For i = 0 To db.TableDefs.Count - 1

    List1.AddItem db.TableDefs(i).Name

    Next i

  3. #3
    Member
    Join Date
    Aug 1999
    Posts
    52

    Post

    hi sushant,

    Its workin fine but even the system tables are also listed how to eliminate the system tables..

    kandan

  4. #4
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    Sure!

    Code:
        Dim db As Database
        Dim tb As TableDef
        
        Set db = Workspaces(0).OpenDatabase("D:\Microsoft Visual Studio\VB98\Nwind.mdb")
        For i = 0 To db.TableDefs.Count - 1
            If db.TableDefs(i).Attributes = 0 Or db.TableDefs(i).Attributes > 2 Then
                List1.AddItem db.TableDefs(i).Name
            End If
        Next
    ------------------

    Serge

    Software Developer
    Serge_Dymkov@vertexinc.com
    Access8484@aol.com
    ICQ#: 51055819


  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jan 1999
    Posts
    239

    Post

    To Sushant and Serge, both methods work
    great, thank you for your help, I really
    appreciate it.

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