Solved

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

Posted on 2006-06-14
10
308 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
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month4 days, 15 hours left to enroll

635 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