Results 1 to 5 of 5
  1. #1
    data808 is offline Noob
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    727

    Macro of VBA to stop other macros if I click cancel for print

    I have a form that has a button to print. The form has the allow data entry property set to "yes" so the form is always set to "new" record. In other words you cannot navigate to other records in the form. I made it like this so the user cannot go back to old records to delete or edit them. I also set the print button to close and reopen this form to sort of refresh it, so its blank again after they print it. So the print button will trigger the print window where it has some settings for the print job and the user can then click on print or cancel. If they click print, everything does what I want it to do. The record will print and then it will save into the database table because the macro will close the form and then another macro will open it back up blank and ready for the next new record. However, if they click cancel because they want to make a change to the record before they print, it will still go through the same process and save the record and refresh the form. I do not want this to happen if the user clicks on cancel. How do you get this to stop?

    Thanks.

  2. #2
    trevor40's Avatar
    trevor40 is offline Advanced db Manager
    Windows XP Access 2003
    Join Date
    Feb 2014
    Location
    Australia
    Posts
    402
    supply the code behind the button event and we will see whats going on, but it will be an easy fix

  3. #3
    data808 is offline Noob
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    727
    Well the thing is, its a bunch of macros right now. I do not know how to do VBA. I know how to convert the macros to VBA code if you want but all I have running behind the button right now are these macros:

    Run Command - Print Selection
    Close Form - Form1
    Open Form - Form1

    Form1 is the name of the form. So the Run Command - Print Selection macro is the one that initiates the print window. This is where the user will either click on print or cancel.

  4. #4
    trevor40's Avatar
    trevor40 is offline Advanced db Manager
    Windows XP Access 2003
    Join Date
    Feb 2014
    Location
    Australia
    Posts
    402
    When you convert a macro it works just the same but allows mich more freedom in design.
    convert the first macro you call with the button and post theat code, I'll reply with a way for you to do what you need to do.

  5. #5
    data808 is offline Noob
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    727
    Sorry for the late reply. I don't have the code with me right now but would you be able to convert those macros above and add the code to it? If not, its ok. I will try get you the code soon. Thanks for helping me out on this. Really appreciate it.

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

Similar Threads

  1. Cancel button in Quit Macro
    By ashu.doc in forum Forms
    Replies: 3
    Last Post: 09-19-2012, 04:40 PM
  2. Replies: 2
    Last Post: 05-05-2012, 02:34 AM
  3. VBA to cancel a macro
    By GraemeG in forum Programming
    Replies: 1
    Last Post: 03-26-2011, 04:50 PM
  4. Stop SendObject Macro
    By OpsO in forum Import/Export Data
    Replies: 1
    Last Post: 08-19-2010, 09:56 AM
  5. Replies: 2
    Last Post: 11-29-2009, 12:00 PM

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