Share via

MS Access - Create a Button to Run a query

Anonymous
2016-06-18T15:00:33+00:00

Sir/Madam,

   I have got about 70 queries already created. The thing i want is that if i create a button to "Run Query", it can run only 1 query. I want to create a button, which when clicked, asks me to enter the respective query name (to be opened). So if i enter the name of query, that particular query opens.

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

6 answers

Sort by: Most helpful
  1. Anonymous
    2016-06-18T15:41:25+00:00

    theDBguy i have tried that, but combobox or listbox only takes data in each query. I want the query itself to be listed

    Was this answer helpful?

    2 people found this answer helpful.
    0 comments No comments
  2. Anonymous
    2016-06-18T18:08:31+00:00

    thanks theDBguy. I got it

    I have another question. Can we create a button to openform in query

    Was this answer helpful?

    0 comments No comments
  3. DBG 11,711 Reputation points Volunteer Moderator
    2016-06-18T15:50:12+00:00

    Try the following SQL as a Row Source for your Combobox or Listbox:

    SELECT [Name] FROM MSysObjects WHERE [Name] Not Like "~*" AND [Type]=5 ORDER BY [Name]

    Hope it helps...

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2016-06-18T15:38:25+00:00

    Thats pretty good thought. Can you suggest me the way of linking all the queries to the Combobox or List box

    Was this answer helpful?

    0 comments No comments
  5. DBG 11,711 Reputation points Volunteer Moderator
    2016-06-18T15:25:21+00:00

    If you ask the user to enter the name of a query, they could make a mistake and enter a wrong name. Then, your code to open the query will fail or get an error. It would be better to use a Combobox or Listbox showing the names of all your queries and all the user has to do is select the one he or she wants to run. Just a thought...

    Was this answer helpful?

    0 comments No comments