Solved

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

Posted on 2006-06-14
10
293 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Cannot enter table caption text in Word protected document 6 123
Visual Studio 2005 text editor 10 38
VB 6 error 5 in windows 10 but not in XP 7 55
Automatic Email Reminder 4 36
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…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

776 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