QueryUnload

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steve

    QueryUnload

    Hi Huys,

    When the "X" is pressed, I know that QueryUnload is called.

    I want to be able to put up a box, asking the user if they are sure.. If
    yes then
    the programme will end. If the answer is no, how do I prevent the form from
    unloading?

    TIA.

    Steve.


  • Larry Serflaten

    #2
    Re: QueryUnload

    "Steve" <alex_is_a_cunt @twat.com> wrote[color=blue]
    > When the "X" is pressed, I know that QueryUnload is called.
    >
    > I want to be able to put up a box, asking the user if they are sure.. If
    > yes then
    > the programme will end. If the answer is no, how do I prevent the form from
    > unloading?[/color]


    Did you try changing Cancel to True? Highlight QueryUnload in
    the VB code window and press F1 for help on that event....

    LFS







    -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
    http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
    -----== Over 100,000 Newsgroups - 19 Different Servers! =-----

    Comment

    • Randy Birch

      #3
      Re: QueryUnload


      cancel = msgbox ( "want to quit", vbquestion or vbYesNoCancel, "Eh?") =
      vbYes

      --

      Randy Birch
      MVP Visual Basic

      Please respond only to the newsgroups so all can benefit.

      There' no place like 127.0.0.1


      "Steve" <alex_is_a_cunt @twat.com> wrote in message
      news:rhadnYOMW-c4Z5_dSa8jmw@ka roo.co.uk...
      : Hi Huys,
      :
      : When the "X" is pressed, I know that QueryUnload is called.
      :
      : I want to be able to put up a box, asking the user if they are sure.. If
      : yes then
      : the programme will end. If the answer is no, how do I prevent the form
      from
      : unloading?
      :
      : TIA.
      :
      : Steve.
      :
      :


      Comment

      • Lovely Dola

        #4
        Re: QueryUnload

        Set the 1st parameter to True to prevent the form from unloading.


        "Steve" <alex_is_a_cunt @twat.com> wrote in message news:<rhadnYOMW-c4Z5_dSa8jmw@ka roo.co.uk>...[color=blue]
        > Hi Huys,
        >
        > When the "X" is pressed, I know that QueryUnload is called.
        >
        > I want to be able to put up a box, asking the user if they are sure.. If
        > yes then
        > the programme will end. If the answer is no, how do I prevent the form from
        > unloading?
        >
        > TIA.
        >
        > Steve.[/color]

        Comment

        • QuickHare

          #5
          Re: QueryUnload

          > When the "X" is pressed, I know that QueryUnload is called.[color=blue]
          >
          > I want to be able to put up a box, asking the user if they are sure.. If
          > yes then
          > the programme will end. If the answer is no, how do I prevent the form from
          > unloading?[/color]
          Use this event to show your Msgbox. The variable Cancel contains whether the
          form continues or not.
          Basically,

          Private Sub Form_QueryUnloa d(Cancel As Integer, UnloadMode As Integer)
          If MsgBox("Are you sure?", vbYesNo, "Quit") = vbNo Then Cancel = 1
          End Sub

          does a good job.

          --
          QuickHare
          QuickHare @ Hotmail. com






          Comment

          • Steve

            #6
            Re: QueryUnload


            "QuickHare" <QuickHare@Hotm ail.c> wrote in message
            news:bu1g4g$1kn 5q9$1@athena.ex .ac.uk...[color=blue][color=green]
            > > When the "X" is pressed, I know that QueryUnload is called.
            > >
            > > I want to be able to put up a box, asking the user if they are sure..[/color][/color]
            If[color=blue][color=green]
            > > yes then
            > > the programme will end. If the answer is no, how do I prevent the form[/color][/color]
            from[color=blue][color=green]
            > > unloading?[/color]
            > Use this event to show your Msgbox. The variable Cancel contains whether[/color]
            the[color=blue]
            > form continues or not.
            > Basically,
            >
            > Private Sub Form_QueryUnloa d(Cancel As Integer, UnloadMode As Integer)
            > If MsgBox("Are you sure?", vbYesNo, "Quit") = vbNo Then Cancel = 1
            > End Sub
            >
            > does a good job.
            >
            > --
            > QuickHare
            > QuickHare @ Hotmail. com
            >
            >
            >
            >[/color]

            Thankyou for all you reply's.

            Steve!


            Comment

            • Randy Birch

              #7
              Re: QueryUnload

              If MsgBox("Are you sure?", vbYesNo, "Quit") = vbNo then the result of the
              Msgbox call is True.

              If MsgBox("Are you sure?", vbYesNo, "Quit") = vbYes then the result of the
              Msgbox call is also True.

              If Cancel is set to True, the unload is aborted. Therefore,

              Cancel = MsgBox("Are you sure?", vbYesNo, "Quit") = vbNo

              or, if you want a more positive approach ...

              Cancel = MsgBox("Are you sure?", vbYesNo, "Quit") = vbYes

              does it without the If.

              --

              Randy Birch
              MVP Visual Basic

              Please respond only to the newsgroups so all can benefit.

              There's no place like 127.0.0.1



              Comment

              • QuickHare

                #8
                Re: QueryUnload

                > If MsgBox("Are you sure?", vbYesNo, "Quit") = vbNo then the result of the[color=blue]
                > Msgbox call is True.[/color]
                Only if the user selects No (why would the user want it closed if their not sure
                to close it?).
                [color=blue]
                > If MsgBox("Are you sure?", vbYesNo, "Quit") = vbYes then the result of the
                > Msgbox call is also True.[/color]
                Only if the user selects Yes.
                [color=blue]
                > does it without the If.[/color]
                Fair enough. I just threw it in for ease of understanding. Those wanting to know
                more about MsgBox results would hopefully look it up in help!

                --
                QuickHare
                QuickHare @ Hotmail. com


                Comment

                Working...