Solved

Alternate causes of "Can't show non-modal form when modal form is displayed..."

Posted on 2006-06-14
10
296 Views
Last Modified: 2010-04-07
I've written a project in Visual Basic 6.0 and on some clients, to a greater or lesser extent, they get the error "Can't show non-modal form when modal form is displayed" when no modal form is displayed/loaded.
- I've tried code to detect all forms loaded in the project when this occurs but none are returned, besides the MDI and non-modal child(s). eg I've used the Forms collection.
- This error never occurs on our development PCs

Q1. Has anyone come across this issue or heard of a relevant bug in VB?
Q2. If there is 2 or more instances of the same program open, could this cause the error?
Q3. If there is 2 or more instances of different VB programs open, could this cause the error?
Q4. We have instant messaging freeware installed ICQ, could this cause the error?
Q5. Could Outlook being open cause the error?

I have been struggling with this for many years without any joy?

P.S. Please do NOT paste in a MSDN description of  "Can't show non-modal form when modal form is displayed"
0
Comment
Question by:RobertEnglish
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 26

Expert Comment

by:EDDYKT
ID: 16902361
>>- This error never occurs on our development PCs


are you running from ide or from exe?
0
 

Author Comment

by:RobertEnglish
ID: 16902450
>>- >>- This error never occurs on our development PCs


>>- are you running from ide or from exe?

Both - and I can never get it to replicate
0
 
LVL 4

Expert Comment

by:g_johnson
ID: 16904702
my guess is that something is happening such that the program wants to show the form twice.  how do you show the form?  where in the program?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:RobertEnglish
ID: 16904758
>>- my guess is that something is happening such that the program wants to show the form twice.  how do you show the form?  where in the program?

Either (for non-modal forms)
 Load frmX:  frmX.Show
Or (for modal forms)
 Load frmX:  frmX.Show vbModal
Or (I tried this as an alternative to vbModal to see if it'd eliminate the problem, which it didn't)
 Load frmX:  frmX.Show , frmMDI

Unloading a form
 Unload frmX: Set frmX = Nothing
0
 
LVL 4

Accepted Solution

by:
g_johnson earned 250 total points
ID: 16906212
I'm sorry, what I meant was in what routine do you show the forms.
since this only happens on some machines, it's possible that a form is not being completely closed due to cpu speed and then your program is trying to open it again, e.g.
0
 
LVL 10

Assisted Solution

by:fostejo
fostejo earned 250 total points
ID: 16907189
RobertEnglish,

First, to answer your questions :

Q1. Has anyone come across this issue or heard of a relevant bug in VB?
A1. Yes, seen it before and it's likely NOT a VB bug but a glitch in your code..
Q2. If there is 2 or more instances of the same program open, could this cause the error?
A2. Depends on whether the dialogs are Application or System Modal - if System modal then possibly.
Q3. If there is 2 or more instances of different VB programs open, could this cause the error?
A3. As per A2.
Q4. We have instant messaging freeware installed ICQ, could this cause the error?
A4. Unlikely.
Q5. Could Outlook being open cause the error?
A5. Unlikely.

Problems like this are usually (as you no doubt already know!) pretty subtle is it's almost certainly an issue with your coding rather than VB itself. When I've exhausted all the usual ways to debug, I often resort to creating a 'debug' build of the software causing the issue, allowing me to see what the flow is 'internally' and also, when it errors directing me toward the specific line triggering the issue - so, a couple of ideas:

If you've not already got a similar tool, download MZ-Tools (http://www.mztools.com/v3/mztools3.htm) and

1. While probably frowned upon in some circles... add line numbers to all the code in your project using something like MZ-Tools (http://www.mztools.com/v3/mztools3.htm)

2. Again, using MZ-Tools, ensure every sub/function/routine has an appropriate error handler to either show or log any errors encountered noting their error number (err.number) , description (err.description) and, importantly, the Line Number it occurred on using the undocumented ERL keyword. (You can easily configure an 'error handler' template in MZ-Tools that you can then paste into any new or existing routine making the job pretty quick and error free)

3. If possible, have a 'ImCurrentlyHere' routine which every other routine calls on entry - this routine would, for instance, update the text in a StatusBar control with the name of the current procedure that's executing - this can be surprisingly useful just to gain a better understanding of what your software is actually doing when it's doing 'nothing'

Hope that helps..
0
 
LVL 4

Expert Comment

by:g_johnson
ID: 17292881
all the comments made were pertinent, in my view
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
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…

762 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