Results 1 to 7 of 7

Thread: Trapping the close button

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2003
    Location
    chennai
    Posts
    19

    Trapping the close button

    hi,
    can we trap the clicking of close button of a vb form. if so can even trap the alt + f4 command.
    my main prob is i want to display the msgbox before closing the project. so that by clicking the ok button it has to close if they click cancel nothing should happen.
    i tried to write it in unload function but i didnt find any solution.
    plz can anybosy helps me plzzzz.

  2. #2
    Addicted Member
    Join Date
    Sep 2000
    Location
    UK
    Posts
    199
    Try looking into the query unload event. This has a parameter called UNLOADMODE. This should be what you are looking for.

    Best Of Luck

  3. #3
    Lively Member
    Join Date
    May 2003
    Location
    Los Angeles
    Posts
    126
    Try this ... I believe it works for both
    VB Code:
    1. Private Sub Command1_Click()
    2. Unload Me
    3. End Sub
    4.  
    5. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    6.      If UnloadMode = vbFormControlMenu Then
    7.           MsgBox "You cannot use that button", vbInformation + vbOKOnly, "Not allowed"
    8.           Cancel = True
    9.      End If
    10. End Sub

  4. #4
    Supreme User Madboy's Avatar
    Join Date
    Oct 2003
    Location
    England
    Posts
    3,253

    Re: Trapping the close button

    Originally posted by vbinfant
    i tried to write it in unload function but i didnt find any solution.
    plz can anybosy helps me plzzzz.
    Unload isnt a function

  5. #5
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217

    Re: Re: Trapping the close button

    Originally posted by Madboy
    Unload isnt a function
    that's very unecessary.... don't do that
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  6. #6
    Supreme User Madboy's Avatar
    Join Date
    Oct 2003
    Location
    England
    Posts
    3,253

    Re: Re: Re: Trapping the close button

    Originally posted by BuggyProgrammer
    that's very unecessary.... don't do that
    Sorry, but neither was your reply

    Just letting him know, it might confuse people later on

  7. #7
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217

    Re: Re: Re: Re: Trapping the close button

    Originally posted by Madboy
    Sorry, but neither was your reply

    Just letting him know, it might confuse people later on
    what is one post if you wouldn't do that in that future
    Remember, if someone's post was not helpful, you can always rate their post negatively .

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