Solved

MDI forms can't be Modal

Posted on 2004-09-02
2
135 Views
Last Modified: 2010-05-02
In the following code "frmMain" is a MDI form. Since MDI forms can't be Modal, the execution of the code will continue to "GlobalErrorHandlerDestroy" and deactivate
my error handler as quickly as it has been activated. Is there any workaround? In other words, I only want "GlobalErrorHandlerDestroy" to be exexuted when the
program is being terminated (fMain being closed).

Public Sub Main()
Const csSUBNAME As String = "main"
On Error GoTo ErrorHandler

    GlobalErrorHandlerCreate
   
    Set fMain = New frmMain
       
    fMain.Show  '(VBModal can be used here)
 
    GlobalErrorHandlerDestroy
   
Exit Sub
ErrorHandler:
    If go_Err Is Nothing Then
        MsgBox "Could not initialise error handler.", vbCritical
    Else
        If go_Err.ErrReport(Err, Erl, csMODULENAME, csSUBNAME) Then Resume
    End If
End Sub
0
Comment
Question by:inorse
2 Comments
 
LVL 22

Expert Comment

by:DarkoLord
ID: 11967594
One way would be to create another function and call it from frmMain when it is being closed....

Darko
0
 
LVL 32

Accepted Solution

by:
Erick37 earned 250 total points
ID: 11968173
Why not set frmMain as your startup form.  Then create your error handler in MDIForm_Load and destroy it in MDIForm_Unload?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

867 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now