Results 1 to 4 of 4
  1. #1
    4 Star Lounger
    Join Date
    Nov 2002
    Location
    London, Gtr London, England
    Posts
    496
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Dear Loungers,

    Can anyone explain what happens in a macro with several actions, is each actioncompleted before the next action. I can see that for things such as navigation etc this would be the case, but waht about if the action was RunCode would the code have to finish before the next macroaction, or does it get initiated and the next action will then carry on so I have two process running?

    thank you................. liz

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    Good question.
    Most of the time "yes", but it is hard to know for sure about any specific action. In VBA code it is sometimes necessary to put something in to force the code to wait at a specific step before moving on the next one.

    Code:
    Do Events
    is the simplest. Or a Delay loop.

    Searching for your question I found this which includes:

    Access doesn’t always wait for one action to complete before going on to the next one. For example, an OpenForm action merely starts a task to begin opening the form. Particularly if the form displays a lot of data, Access might take several seconds to load all the data and finish displaying the form. Because you’re running Windows, your computer can handle many tasks at once. Access takes advantage of this by going to the next task without waiting for the form to completely open. However, because this macro is designed to maximize the WeddingList form, the form must be completely open in order for this to work.
    Regards
    John



  3. #3
    4 Star Lounger
    Join Date
    Nov 2002
    Location
    London, Gtr London, England
    Posts
    496
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Dear John,

    Thank you. I have now rooted around but am a little confused because there seem to be several ideas about what DoEvents actually does, for example these are statements I have found:
    1. DoEvents statement should force all statements prior to it to execute before any following statements to execute
    2. DoEvents allows Windows to do things. It passes control to the OS and not the database.


    These two statement seem contradictory, however I now think they are both true since MS say this "DoEvents passes control to the operating system. Control is returned after the operating system has finished processing the events in its queue and all keys in the SendKeys queue have been sent.".So I think control is passed to the OS but since Access has initiated previous instructions then these are executed before control returns to Access. If this is true then DoEvents will be useful unless the OS has a lot of parallel processes to complete.

    Can you confirm that I have the right end of the stick?

    liz

  4. #4
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    I am not sure that I am any clearer about this than you are.

    My understanding is that some of the tasks performed by macros or VBA code are not actually performed by Access itself, but by the OS, and those are the ones where there is a risk of things not happening in order.

    So when Access passes a job over to the OS, it may proceed immediately to the next step in the Macro/Code without waiting for the OS to finish the job it just passed over.

    Do Events passes control back to Windows, so it allows those tasks to be finished.
    Regards
    John



Posting Permissions

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