Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


MDI FORM  closing problem

Posted on 2003-03-20
Medium Priority
Last Modified: 2011-09-20
Hi all
i am programming a simple application using vbasic, i have a MDIForm and 2 other child form of this MDI. When i start the mdi form i open the 2 other child. In the Unload event of the MDI Form i want to ask the user if he is sure he wants to exit but what happen is that the 2 child forms are closed before the msgbox appear.
Any help please
Question by:mmalwan

Accepted Solution

Cimperiali earned 210 total points
ID: 8172415
Use the QueryUnload event:

Private Sub MDIForm_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Dim retVar As VbMsgBoxResult
retVar = MsgBox("Do you want to quit?", vbYesNo)
If retVar = vbNo Then
     Cancel = True 'stop unloading
End If
End Sub

Expert Comment

ID: 8172456
Use "Exit" Menu in MDI Form and
in code side

Private Sub exit_Click()
On Error Resume Next
Unload ActiveForm

dim i as integer
 i = Msgbox("Are you sure you want to exit",vbYesNo)
 if i = 6 then
  unload me
 end if
End Sub

Author Comment

ID: 8179377
thanks all
this is what i want

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month10 days, 14 hours left to enroll

572 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