Microsoft Access - select query based on contents of combo box

  • Good Afternoon,


    I have an access form with a combo box (combo_rule) that lists a number of queries.


    When I hit the run button, I woul like to run the query that has been selected in the combo box.


    Can anyone advise the best way to do this


    Thanks


    Mark

  • Mark


    You could use DoCmd.OpenQuery for that, something like this

    Code
    1. DIm strQueryName As String
    2. strQueryName = Me![combo_rule].Value
    3. DoCmd.OpenQuery strQueryName, acViewNormal


    Note, you can change the 2nd argument View how you want the query displayed/what you want to do with it, see here for more information.