Results 1 to 5 of 5

Thread: How can i get the table in a listfield???

  1. #1

    Thread Starter
    Hyperactive Member Libero's Avatar
    Join Date
    Jun 2000
    Location
    Swedish viking
    Posts
    460

    Unhappy

    How can i get the tables from an accessdatabase in to a listfield???

  2. #2
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Thumbs up DAO.TableDef & DAO.Field

    Will this help you? The sample code will list all the available table in a access database as well as all the respective fields.

    Code:
    Dim db As DAO.Database
    Dim tbl As DAO.TableDef
    Dim fld As DAO.Field
    
    Set db = DAO.OpenDatabase("C:\db3.mdb", False, False)
    For Each tbl In db.TableDefs
        List1.AddItem tbl.Name
        For Each fld In tbl.Fields
            List1.AddItem "---" & fld.Name
            Set fld = Nothing
        Next
        Set tbl = Nothing
    Next
    db.Close
    Set db = Nothing

  3. #3

    Thread Starter
    Hyperactive Member Libero's Avatar
    Join Date
    Jun 2000
    Location
    Swedish viking
    Posts
    460
    Sorry! I´m new at databaseprogging. How do i define the "DAO.Database"

    Dim db As DAO.Database ' <--- user defined type not defined
    Dim tbl As DAO.TableDef
    Dim fld As DAO.Field

    Set db = DAO.OpenDatabase("C:\Program Files\Microsoft Visual Studio\Projekt\Softsheet4\Base.mdb", False, False)
    For Each tbl In db.TableDefs
    List1.AddItem tbl.Name
    For Each fld In tbl.Fields
    List1.AddItem "---" & fld.Name
    Set fld = Nothing
    Next
    Set tbl = Nothing
    Next
    db.Close
    Set db = Nothing


    Hope on an answer :-)

  4. #4
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    If you have a data control on your form,
    Dim db as Database ' or Public db as Database
    if not, you need to make a reference to dao from the references.
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  5. #5

    Thread Starter
    Hyperactive Member Libero's Avatar
    Join Date
    Jun 2000
    Location
    Swedish viking
    Posts
    460
    Thanx to both!! I got it now... :-)))

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