Results 1 to 5 of 5

Thread: [RESOLVED] Cancel Form

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Posts
    17

    Resolved [RESOLVED] Cancel Form

    Is there a way to detect if someone pressed cancel on form?
    I have a procedure that call two form after each other. The first if the use click ok updates some registry entries. The second on then show the display with the new enties. If The user presses cancel I do not want the second for to show.
    Right now I am just doing
    frmSetUp.Show vbModal
    frmDisplay.Show vbModal

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Cancel Form

    Welcome to the forums.

    What do you mean by "cancel"? Hitting the close, X, button in the upper right hand corner?

  3. #3
    Addicted Member
    Join Date
    Jan 2006
    Posts
    248

    Re: Cancel Form

    Quote Originally Posted by Ron22
    Is there a way to detect if someone pressed cancel on form?
    I have a procedure that call two form after each other. The first if the use click ok updates some registry entries. The second on then show the display with the new enties. If The user presses cancel I do not want the second for to show.
    Right now I am just doing
    frmSetUp.Show vbModal
    frmDisplay.Show vbModal

    Have the cancel button place like "CANCELED" or something either in a variable that can be read or in it's form's tag.
    Like Form1.tag="CANCELED"
    then just check the tag before opening the second form.
    Mike

  4. #4
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: Cancel Form

    Add a public boolean to your main Form, and set it to False, so you'll set it to true when the user clicks OK in the second Form.
    I'll call your main form Form1
    VB Code:
    1. Public mContinue  As Boolean 'This one can be accessed from the other Forms
    2.  
    3. Private Sub InitProcess()
    4.     mContinue = False
    5.     frmSetUp.Show vbModal
    6.     If mContinue Then
    7.         frmDisplay.Show vbModal
    8.     End If
    9. End Sub
    Then in frmSetUp, in the code for the Ok button event, add.
    VB Code:
    1. '...Code..
    2.     Form1.mContinue = True
    3.     Unload Me
    If you don't want to add a public variable, use property get and propery set, with a private variable.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Posts
    17

    Re: Cancel Form

    First Hack what I ment by canceld was press the button labled "Cancel" Cancel set to true. So either the operator pressed esc or the x button or pressed cancel.
    jcis & MikeJoel Thanks for the quick answer

Posting Permissions

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



Click Here to Expand Forum to Full Width