Solved

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

Posted on 2006-06-14
10
288 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
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…

705 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

19 Experts available now in Live!

Get 1:1 Help Now