Results 1 to 3 of 3

Thread: on unload, cancel(solved)

  1. #1

    Thread Starter
    Fanatic Member scr0p's Avatar
    Join Date
    Oct 2002
    Location
    VA
    Posts
    720

    on unload, cancel(solved)

    How do I let the user cancel closing the app? If they press the X button by accident and it says 'want to save, yes no cancel' for example.
    Last edited by scr0p; Nov 11th, 2002 at 11:28 AM.
    asdf

  2. #2
    Fanatic Member
    Join Date
    Apr 2002
    Posts
    638
    VB Code:
    1. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    2.     If (MsgBox("Are you sure?", vbYesNo) = vbNo) Then
    3.         Cancel = True
    4.     End If
    5. End Sub

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    Just a minor addition to tr0n's code:

    VB Code:
    1. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    2.   If DataUnsaved Then '<-- Check to see if the needs to be saved first
    3.     If (MsgBox("Are you sure?", vbYesNo) = vbNo) Then
    4.         Cancel = True
    5.     End If
    6.   End If
    7. End Sub
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

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