Using a single button to run multiple queries

jw08

Registered User.
Local time
Today, 10:46
Joined
Aug 14, 2012
Messages
13
Hi all I have a very simple question

I have added a button on a form to run queries, appearently the button only runs one query, what should I do to make it run multiple queries?

If I need to use VB code, can someone give me an example of code as I have no idea how it works:-(

Thank you very much!
 
Hi and welcome to the wonderful AWF.. :)

What have you come up with so far? Have you used DoCmd to run Queries?? You can for sure run any number of queries with DoCmd..
 
I just added button from the tool bar and it lets you to choose the function of the button and also to link to the query you want to run. I don't know the DoCmd at all I'm afraid, where should I add this DoCmd code to?

Thanks
 
Not to worry.. Check the following attachment before reading any further..

Now using DoCmd.. You will be opening the Query that you have saved.
something in the lines of..
Code:
DoCmd.OpenQuery "QueryName1"
DoCmd.OpenQuery "QueryName2"
DoCmd.OpenQuery "QueryName3"
But make sure that the QueryNames match the ones you have.. Hope this helps..
 

Attachments

  • CheckThisAttach.jpg
    CheckThisAttach.jpg
    82.7 KB · Views: 3,584
Thanks Pre-eugin

I have tried, but it still doesn't work. not sure why though

Please see attached image, that's the code I use, let me know if there's any wrong with my coding.

Thanks again!
 

Attachments

  • image001.jpg
    image001.jpg
    91.9 KB · Views: 1,828
I see nothing wrong with the code.. Just make sure that you have spelled the Query names right.. Advice on them would be Avoiding Spaces instead of "Company Name - Unique" Try using "UniqueCompanyName_Qry".. Also use a MsgBox and see if it pops out, we need to make sure that the Command button responds in the first place.. So try this code..
Code:
Private Sub Command38_Click()
Call MsgBox("Can you see this message? Yes?")
End Sub
If you could did not see the message box then the button is not working, delete it and put in a new button, now instead of using the wizard (i.e. hit cancel) and then follow the steps I gave you earlier..
 
Sorry to trouble you again, so I added this message box and it worked, but still my queries were not runned properly, what I should do now?
 
Hi there jw08, I do not understand.. It works perfectly for me..
Do you somewhere in your code have an On Error Resume Next statement?? Or something to avoid errors like Exit Sub??

Try also to put debugging methods like message boxes after every single query and see if the number of message boxes that pops up matches..
 
Hello,

You can put all your queries in the Macro.
You do not need to know VBA.

in Panel , Select Insert--> Macro

and then Fill in the Macro:

Add New Action --> Open OpenQuery
Enter Query Name

Then Add another Action --> Open Query
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
visit msaccess2010.com for more help/ tutorials/bugs and fixes
 

Users who are viewing this thread

Back
Top Bottom