List Box with all tables, queries and forms of my database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • isetea
    New Member
    • Sep 2006
    • 44

    List Box with all tables, queries and forms of my database

    Hi,

    is there any VBA code I can try to get all tables, queries and forms of my database selected and displayed in a list box of a form? And also the list box must be always held the current vlaues. Meaning if I enter a new table or form, the list box needs to show it.

    Any help is much appreciated. :)

    Thanks
  • MMcCarthy
    Recognized Expert MVP
    • Aug 2006
    • 14387

    #2
    Create a lookup table called ObjectType as follows:

    TypeID TypeDesc
    ====== ========
    1 Table
    5 Query
    -32768 Form
    -32764 Report

    You could then use a query on the Msysobjects table as follows:
    SELECT DLookUp("[TypeDesc]","ObjectType", "[TypeID]=" & [MsysObjects].[Type]) AS ObjType, MsysObjects.Nam e
    FROM MsysObjects
    WHERE (((DLookUp("[TypeDesc]","ObjectType", "[TypeID]=" & [MsysObjects].[Type])) Is Not Null) AND ((MsysObjects.N ame) Not Like '~*' And (MsysObjects.Na me) Not Like 'MSys*'))
    ORDER BY DLookUp("[TypeDesc]","ObjectType", "[TypeID]=" & [MsysObjects].[Type]), MsysObjects.Nam e;



    Originally posted by isetea
    Hi,

    is there any VBA code I can try to get all tables, queries and forms of my database selected and displayed in a list box of a form? And also the list box must be always held the current vlaues. Meaning if I enter a new table or form, the list box needs to show it.

    Any help is much appreciated. :)

    Thanks

    Comment

    • isetea
      New Member
      • Sep 2006
      • 44

      #3
      I did like you said. But it is given me an error message saying "data type mismatch in criteria expression". Also I can't exit the error message any more, need to end task via task manager.
      Are you sure it works?

      Originally posted by mmccarthy
      Create a lookup table called ObjectType as follows:

      TypeID TypeDesc
      ====== ========
      1 Table
      5 Query
      -32768 Form
      -32764 Report

      You could then use a query on the Msysobjects table as follows:
      SELECT DLookUp("[TypeDesc]","ObjectType", "[TypeID]=" & [MsysObjects].[Type]) AS ObjType, MsysObjects.Nam e
      FROM MsysObjects
      WHERE (((DLookUp("[TypeDesc]","ObjectType", "[TypeID]=" & [MsysObjects].[Type])) Is Not Null) AND ((MsysObjects.N ame) Not Like '~*' And (MsysObjects.Na me) Not Like 'MSys*'))
      ORDER BY DLookUp("[TypeDesc]","ObjectType", "[TypeID]=" & [MsysObjects].[Type]), MsysObjects.Nam e;

      Comment

      • MMcCarthy
        Recognized Expert MVP
        • Aug 2006
        • 14387

        #4
        In the lookup table ObjectType did you declare the TypeID as a Number (Long Integer).

        I tested the query and it did work.


        Originally posted by isetea
        I did like you said. But it is given me an error message saying "data type mismatch in criteria expression". Also I can't exit the error message any more, need to end task via task manager.
        Are you sure it works?

        Comment

        • isetea
          New Member
          • Sep 2006
          • 44

          #5
          :o
          No I did not! Sorry.

          It's working now. I needed to add Tpe 6 as well because there were linked tables.

          Thanks very much for you help! :)

          Originally posted by mmccarthy
          In the lookup table ObjectType did you declare the TypeID as a Number (Long Integer).

          I tested the query and it did work.

          Comment

          • thewolfsden5
            New Member
            • Feb 2008
            • 1

            #6
            This worked in the query but I was not able to view the field "Names" in the list box of the form. The only field that was displayed was ObjType.

            Comment

            Working...