Results 1 to 2 of 2
  1. #1
    GraemeG is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Feb 2011
    Posts
    152

    VBA to cancel a macro

    Hello.
    I have the following code which runs a macro.
    However I want to be able to give the users the option to cancel and not run the macro within the message box that appears.
    Any help appreciated.
    Thanks

    Code:
    Private Sub Command35_Click()
    MsgBox "Warning! You must be connected to the network to syncronise survey data" & vbNewLine & "If you wish to procedd please select Ok" & vbNewLine & "If you do not wish to sync please select Cancel", vbExclamation + vbOKCancel, "Syncronise Data"
    DoCmd.RunMacro "Output_Survey_Data"
    End Sub


  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    it should be:
    Code:
    if msgbox("warning!  yada yada...) = vbcancel then
       exit sub
    else
       'run macro
    end if

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

Similar Threads

  1. Replies: 0
    Last Post: 01-12-2011, 12:43 PM
  2. Cancel new record
    By oakoen in forum Forms
    Replies: 11
    Last Post: 12-18-2010, 09:26 AM
  3. Cancel Selection Event for ListBox
    By is49460 in forum Forms
    Replies: 2
    Last Post: 08-04-2010, 05:53 PM
  4. Yes No Cancel MsgBox
    By Rick West in forum Forms
    Replies: 5
    Last Post: 04-14-2010, 08:57 AM
  5. Cancel listbox selection
    By vba-dev in forum Access
    Replies: 0
    Last Post: 10-26-2009, 12:18 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