[Last Call] Learn how to a build a cloud-first strategyRegister Now


Query Unload Prompt with an option to disable.

Posted on 2006-05-17
Medium Priority
Last Modified: 2011-08-18
I added a message box to ask user if they really want to quit the app or not - something like

How do I add a check box so that the user can choose whether to show the message or not (disable the exit prompt)?

Question by:larrysy
LVL 11

Expert Comment

ID: 16705808
'A crude example:

Option Explicit

Dim m_bOptionQuit       As Boolean

Private Sub Check1_Click()
    Select Case Check1.Value
        Case vbChecked
            m_bOptionQuit = True
        Case vbUnchecked
            m_bOptionQuit = False
    End Select
End Sub

Private Sub Form_Load()
    m_bOptionQuit = True
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    If m_bOptionQuit Then
        If MsgBox("Do you really want to quit?", vbOKCancel) = vbCancel Then
            Cancel = 1
        End If
    End If
End Sub

'I used a simple check box to toggle the module level variable but usually other methods are used to store user settings
' and then retrieved upon program startup.
LVL 12

Expert Comment

ID: 16713961
Store the value of your module-level variable "m_bOptionQuit" into a file (i.e., INI file) or in the Registry.

The next time your program loads, you just read the value from the INI file or the Registry and then assign
it to the "m_bOptionQuit" variable followed by setting the "Value" property of the CheckBox control.
LVL 13

Accepted Solution

Mark_FreeSoftware earned 150 total points
ID: 16715487

you have to create a custom yes/no form, or use subclassing
LVL 11

Expert Comment

ID: 16731155

Author Comment

ID: 16732877
My question is if there is any easy way to add a check box in the pop-up box itself (not the main form) for the purpose.

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

830 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