StopAllMacros Action

Discussion in 'Access Macros' started by Sarita, Jun 3, 2010.

  1. Sarita

    Sarita Guest

    Hi Everyone,

    I've inherited database and I am attempting to make corrections to a Macro.
    The StopAllMacros had the condition listed below and did not work correctly.

    MsgBox("CONTINUE MACRO? If there are any records listed on the query that
    just opened, please press Cancel to exit this macro and then manually update
    the crosswalk; Otherwise press OK to continue.",1)=0

    I want the user to click cancel and manually review the query or click ok
    and continue to run the macro. I would rather put this into VBA but I am
    under a time constraint.

    I would appreciate any help!

    Sarita
     
    Sarita, Jun 3, 2010
    #1
    1. Advertisements

  2.  
    Roger Carlson, Jun 3, 2010
    #2
    1. Advertisements

  3. Sarita,

    This appears to be constructed correctly, to provide an OK and Cancel button
    on the message box, and the macro action to proceed only if the OK button is
    clicked. So at this stage you are going to have to explain in more detail
    what you mean by "did not work correctly". That means saying what is the
    macro Action this Condition is applied to, the other significant actions in
    the macro, what is actually happening (is the MsgBox showing, if so what
    happens when you click the buttons on the MsgBox, any error massage, etc),
    and how what is happening is different from what you desire. Thanks.
     
    Steve Schapel, Jun 3, 2010
    #3
  4. Sarita

    Sarita Guest

    Hi Steve,

    The msgbox does appear with an OK and Cancel button. I want the Cancel
    button to stop the macro and the OK button to continue with the macro.

    The error is: If I click Cancel it continues the macro when it should be
    stopping it.

    The OK button works correctly.

    Was I able to clarify this better?

    Sarita
     
    Sarita, Jun 3, 2010
    #4
  5. Sarita,

    Yes, this has clarified it. Thank you. And what you have described is
    exactly what should happen.

    So, what is the Action that this Condition is applied to?
    And are there any other Actions after this one in the macro? If so, what is
    in the Condition column for these actions?

    Sorry to be asking all these qquestions. But you see, I can't see your
    macro, so I don't know what it does, and therefore I don't know what
    "continue with the macro" means either unless you tell us. Thanks.

    Just to clarify... the "=0" in the Condition expression refers to clicking
    the OK button. So clicking Cancel does not stop the macro, strictly
    speaking - clicking Cancel simply fails to meet the condition of clicking
    OK, so therefore that action should not be performed.
     
    Steve Schapel, Jun 4, 2010
    #5
  6. Sarita

    Sarita Guest

    Hi Steve,

    I've never worked with Macros before so bare with me. This is the only
    StopAllMacros with this condition below in the Macro.

    The action is StopAllMacros.

    The condition: MsgBox("CONTINUE MACRO? If there are any records listed on
    the query that just opened, please press Cancel to exit this macro and then
    manually update the crosswalk; Otherwise press OK to continue.",1)=0

    after this the next action is a query.

    I understand "=0" applies to the OK only and Cancel is suppose to stop the
    query but it doesn't. So what condition do I need so when I click Cancel it
    stops the macro.

    Sarita
     
    Sarita, Jun 4, 2010
    #6
  7. Sarita,

    If the Condition is being aplied to the StopAllMacros action (or probably
    just a StopMacro action would be sufficient), then you want this action to
    be executed if the Cancel button is clicked, not the OK button as at
    present. Therefore you need =1 and not =0, i.e.
    MsgBox("CONTINUE MACRO? If there are any records listed on the query that
    just opened, please press Cancel to exit this macro and then manually update
    the crosswalk; Otherwise press OK to continue.",1)=1
     
    Steve Schapel, Jun 4, 2010
    #7
  8. Sarita

    Sarita Guest

    Hi Steve,

    I ran the macro with the changes you listed below. It worked but in the
    opposite direction meaning: when you clicked OK the macro stopped but if you
    clicked Cancel the macro continued. So I made a minor adjustment and used 2
    instead of 1 and it worked perfectly!

    For Example:

    Action: StopAllMacros
    Condition: MsgBox("CONTINUE MACRO? If there are any records listed on the
    query that just opened, please press Cancel to exit this macro and then
    manually update the crosswalk; Otherwise press OK to continue.",1)=2

    Thank you so much for all your help.

    Sarita
     
    Sarita, Jun 7, 2010
    #8
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.