Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2015
    Posts
    11

    Macro for running several queries one after another

    Hello to you all!!: Thanks for taking some time to read this.

    I've created a user form with a button and I want a macro to run my queries in a particular order (one after another), I don't want the macro to open them, but to run them.

    I'm using this code, but it opens the queries instead.

    Private Sub Comando0_Click()


    DoCmd.OpenQuery ("my_qry")


    End Sub



    I also made a video about what I'm trying to achieve. Please help me

    https://www.youtube.com/watch?v=OPNI...ature=youtu.be

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    I can't watch your video from my present location.

    Are your queries SELECT queries or ACTION queries (Add, Update, Delete)?
    If you use that OpenQuery command on Action query, it will run them without opening them.
    If they are Select queries, what is the point in opening them? Select queries just return data to the screen. They do not change anything (and they do not need to be opened to be "refreshed" or anything like that).

  3. #3
    Join Date
    Jul 2015
    Posts
    11
    Thanks for answering JoeM.

    All of them are SELECT queries. I need to refresh them in order to create several tables that I'm going to export.

    I have a question: When you say that they don't need to be opened in order to refresh them, then, how could I refresh them automatically??

    Thanks for your help!

  4. #4
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    All of them are SELECT queries. I need to refresh them in order to create several tables that I'm going to export.
    You actually don't. Opening a SELECT query does not refresh anything. All it does is return the data to the screen.
    Select queries are "real-time" whenever they are called, and they don't need to be called directly.
    So, if you running a report or form based on a query, exporting the query, or using the query in other action queries, the data will be current as of the time you execute the command. There is no need to open the underlying Select query first.

    Try it for yourself, you will see!

  5. #5
    Join Date
    Jul 2015
    Posts
    11
    Thanks a lot for your help!!! As you can see I'm new with Access!!! Thanks a lot sir!!!

  6. #6
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    You are welcome. Glad to help!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 06-15-2013, 08:05 PM
  2. Running queries, VIA VB, but not running in Order
    By mike02 in forum Programming
    Replies: 6
    Last Post: 06-01-2013, 07:07 AM
  3. macro running in order
    By dumbledown in forum Access
    Replies: 2
    Last Post: 09-03-2012, 08:05 AM
  4. running macro in another DB
    By AdrianoG87 in forum Import/Export Data
    Replies: 1
    Last Post: 09-30-2011, 12:31 AM
  5. Running module from Macro
    By Harley Guy in forum Modules
    Replies: 6
    Last Post: 10-27-2010, 11:05 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums