• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 327
  • Last Modified:

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

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
RobertEnglish
Asked:
RobertEnglish
2 Solutions
 
EDDYKTCommented:
>>- This error never occurs on our development PCs


are you running from ide or from exe?
0
 
RobertEnglishAuthor Commented:
>>- >>- 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
 
g_johnsonCommented:
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
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
RobertEnglishAuthor Commented:
>>- 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
 
g_johnsonCommented:
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
 
fostejoCommented:
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
 
g_johnsonCommented:
all the comments made were pertinent, in my view
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now