Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    May 2002
    Location
    Bristol, Avon, England
    Posts
    110
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Combo box to select queries (2000)

    Does anyone know of a quick way of creating a combo box on a form which will list all or a selection of queries in a database. When a query is selected it will run.

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Combo box to select queries (2000)

    Did you want a quick way of creating a combobox with a list of queries or a quick way of running the selected query or what? If the queries are action queries, you can run them using any of several methods. If they return recordsets, you can't run them at all, you have to do something else with them. Why don't you elaborate further on what you're actually trying to accomplish?
    Charlotte

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Combo box to select queries (2000)

    If you want to list all action queries (delete, append, ...), you can set the RowSource of the combo box to the following SQL statement:

    SELECT Name FROM MSysObjects WHERE Type = 5 And Flags In (32,48,64,80,96) And Left(Name,1) <> "~"

    Or you can create a query with that SQL statement and use that as Row Source.
    RowSourceType should be Table/Query of course.

    In the OnClick routine of the Combo Box, you can put

    DoCmd.OpenQuery [cboQueries]

    Explanation:

    MSysObjects is the system table (hidden unless you have make them visible in Tools/Options) that contains information on all database objects.
    The Type field identifies the kind of object. For queries this is 5.
    The Flags field determines subtypes. Flags 32, 48, ..., 96 denote Delete, Update, Append, MakeTable and Definition queries, respectively.
    System queries have "~" as the first character of their name.

Posting Permissions

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