Logic for cancel in script is not working

Posted on 2005-05-02
Last Modified: 2013-12-18
I have a script that ask 3 questions before it creates the document.  The problem is at any one of the three questions if the user clicks cancel it should kick out of the script and not save the document.  Right now it goes on to the next question and then the next then saves the document

Sub Click(Source As Button)
      Dim ws As New NotesUIWorkspace
      Dim uidoc As NotesUIDocument
      Dim doc As NotesDocument
      Dim db As NotesDatabase
      Dim varReturn As Variant
      Dim strCodeType As String
      Dim intDECheck As Integer
      Dim intWNCheck As Integer
      Dim strOptions(0 To 1) As String
      Dim strDEFlag As String
      Dim strWNFlag As String
      Set db = ws.CurrentDatabase.Database
      strOptions(0) = "RIP"
      strOptions(1) = "Engine"
      varReturn = ws.Prompt(PROMPT_OKCANCELLIST, "Submit Release (step 1/3)", "What type of code release?", "", strOptions)
      strCodeType = varReturn      
      varReturn = ws.Prompt(PROMPT_YESNOCANCEL, "Submit Release (step 2/3)", "Does this RIP/Engine release require counterpart engine/RIP DE approval before releasing .mfg file?")
      intDECheck = varReturn
      varReturn = ws.Prompt(PROMPT_YESNOCANCEL, "Submit Release (step 3/3)", "Does it require WinCSU testing?")
      intWNCheck = varReturn
      If intDECheck = 1 Then
            strDEFlag = "Yes"
            strDEFlag = "No"
      End If
      If intWNCheck = 1 Then
            strWNFlag = "Yes"
            strWNFlag = "No"
      End If
      Set doc = New NotesDocument(db)
      doc.Form = "CodeRelease"
      doc.DECheck = strDEFlag
      doc.WinCheck = strWNFlag
      doc.CodeType = strCodeType
      Call doc.Save(True, False)
      Set uidoc = ws.EditDocument(True, doc)
End Sub
Question by:Jaziar
    LVL 9

    Accepted Solution

    After each call to ws.Prompt, you just need to check the value of the varReturn variable.  

    From the documentation:

    "For type% PROMPT_YESNOCANCEL, returns -1 if you select Cancel. For all other type%s the return value is a variant containing a string array if you press OK, and EMPTY if you press Cancel."

    So after the first prompt, you can add this line:

    If IsEmpty(varReturn) Then Exit Sub

    For the other two add this line afterwards:

    If varReturn = -1 Then Exit Sub

    Author Comment

    Why is no one looking at my NAgMail?

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
    This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now