Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2011
    Posts
    8

    Question Unanswered: Drop down or list of queries to select and run in MS Access 2007 form

    Hi, I am tyring to work out how I can add a drop down menu to a form which lists all or some of the queries in the db.
    Once the the desired query is selected from the drop down then I would like to use a command button to run the query.
    Any help would be greatly appreciated.
    Thanks,
    Gav

  2. #2
    Join Date
    Oct 2003
    Location
    London
    Posts
    341
    Put this SQL behind the Row Source of your Drop Down List;

    Code:
    SELECT MSysObjects.Name
    FROM MSysObjects
    WHERE (((MSysObjects.Type)=5) AND ((MSysObjects.Flags)<>3))
    ORDER BY MSysObjects.Name;
    Object Type refers to the following

    -32764 = Reports
    -32768 = Forms
    5 = Queries
    6 = Tables

    You would then have this code behind your button

    Code:
    If IsNull(Me.List1.Value) = True Then
    MsgBox "Please Select a Query from the table!"
    Else
    DoCmd.OpenQuery Me.List1.Value, , acReadOnly
    End If

  3. #3
    Join Date
    Jun 2011
    Posts
    8

    Thumbs up Thanks!

    Thanks Christy,
    That works great.
    Gav

  4. #4
    Join Date
    Jun 2011
    Posts
    8

    Question Follow up question

    Hi,
    I have a follow up question for this. Is it possible to manually enter only some of the queries into the drop down box rather than call all of them as per Christy's answer above.
    I would like to separate the queries into groups across a few different drop downs on the form.
    Thanks again,
    Gav

Tags for this Thread

Posting Permissions

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