Results 1 to 3 of 3
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington, Cheshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Stopping a macro running (2003)

    I have a macro which runs 1. A report in print preview mode 2. A code module 3. Another report 4. An update query 5. A final report.
    The first report is one which either produces data on which the user has to act or a message saying that there is no data. I want to offer the user the chance to stop the sequence, so the code module at 2 outputs a message asking if they want to cancel the rest of the process (if there is data to investigate) or continue (if there is no data). When the Cancel button is selected , I must stop the rest of the macro running and get back to the switchboard which called the macro. I can't make it do this. In the code module :
    If I use DoCmd.Close acMacro, "macroname" the open report print preview is left open but the rest of the macro commands still execute.
    If I just use DoCmd.Close, the print preview report is closed and the switchboard is closed but remaining macro commands still execute.
    If I use DoCmd.Quit, everything stops (including Access) which is not what I want either
    What's needed, please?
    Thanks
    Silverback.
    Silverback

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Stopping a macro running (2003)

    Why don't you do the whole thing in VBA? You can use Exit Sub to stop execution depending on the button clicked in the message box.

  3. #3
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington, Cheshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Stopping a macro running (2003)

    Well - despite not speaking VBA(!) I have now got it all working as a VBA routine - and the abandonment of the process works fine. Of course, as soon as I had the report calls working in the VBA routine, I had to include the error 2501 catch code! However, as it's all working, a small price to pay.
    Many thanks,
    Silverback
    Silverback

Posting Permissions

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