Results 1 to 4 of 4

Thread: How to read from Access the queries and tables? RESOLVED

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2001
    Posts
    134

    Smile How to read from Access the queries and tables? RESOLVED

    I want to put all the tables and queries names from an Access db to a combo or a list box.
    Last edited by mnavas; Aug 31st, 2003 at 01:21 PM.

  2. #2
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    This may give you a plavce to start (may be other ways).


    In Access, goto Menu: Tools > Options (View) and check the System Objects checkbox.

    Look at the Tables, you should now see all the System Tables.
    One in particular, MSysObjects, holds (amonst other things) ALL the Table Names etc.

    Run an SQL that returns 'Name' based on Type 1 items.

    (Quries are there to as Type 5)


    Bruce.

  3. #3
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    To get a list of table names:
    Code:
    SELECT Name FROM MSysObjects WHERE Type = 1;
    To get list of query names:
    Code:
    SELECT Name FROM MSysObjects WHERE Type = 5;
    additional information:
    Code:
    To get list of Forms:
    SELECT Name FROM MsysObjects WHERE Type =-32768; 
    
    To get list of Reports:
    SELECT Name FROM MsysObjects WHERE Type = -32764;
    
    To get list of Modules:
    SELECT Name FROM MsysObjects WHERE Type = -32761;
    
    To get list of Macros:
    SELECT Name FROM MsysObjects WHERE Type = -32766;
    hope this helps.
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Dec 2001
    Posts
    134
    I found this code.... thanks to all for the help...


    Dim db As DAO.Database
    Dim qdf As DAO.QueryDef

    Set db = OpenDatabase(Data1.DatabaseName)

    For Each qdf In db.QueryDefs
    ' List1.AddItem qdf.Name
    List1.AddItem qdf.SQL
    Next qdf

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