Solved

Runtime error 366 "No MDI form available to load

Posted on 2006-11-17
15
1,751 Views
Last Modified: 2008-01-09
I am using VS6 SP5. I have a simple form that I want to print that is too big to fit
on the entire page when printed, So, I found an article on the internet talking about using MDIChild forms to get around this MS limitation. I made my form a mdiChild form simplying by selecting True beside that value. I ran a test and it worked great, I closed the program , re-opened and now all I get is this error.
How do I set a MDI parent, what is an MDI Parent, just a container ?

Thanks.
0
Comment
Question by:ittechie100
  • 7
  • 5
  • 3
15 Comments
 
LVL 10

Accepted Solution

by:
Clif earned 250 total points
ID: 17965540
You must add an MDI form to your project.

The MDI Parent is just a container where your child forms will appear.  (Well, it's a little more than "just a container", but that will suffice for now.)

Doing:

frmChild.Show

Will bring up the parent form with the child inside.
0
 
LVL 8

Expert Comment

by:drydenhogg
ID: 17965544
The main MDI form (one per app) is the container for all the MDI child forms, you add them to a project in a variety of ways (Project Menu, Add MDI Form), or right click in the project explorer, sub menu add, sub option mdi form.

What seems strange is that you managed to get an mdi child to load without a parent container already being there. I'm unsure as to how you would of achieved that. when you look in your project explorer, do any of the forms have the mdi icon next to them (One large form and a small form icon next to it very greyed out)

To get that MDI child loaded in the first place, you would of needed a parent, so I think there is probably more info needed for this.

hth.
0
 
LVL 10

Expert Comment

by:Clif
ID: 17965633
drydenhogg,
"To get that MDI child loaded in the first place, you would of needed a parent, so I think there is probably more info needed for this."
You can set a form's MDIChild property to True without the project containing an MDIParent form (I agree, you should not be able to do this, but you can).  Doing so, and trying to run the app, will give you the error ittechie100 points out.
0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
LVL 8

Expert Comment

by:drydenhogg
ID: 17965668
clif, compeltely agree but ittechie100 included 'I ran a test and it worked great,  I closed the program , re-opened and now all I get is this error.'

I'm wondering what test worked great at that point in time? No test of loading that form should of worked. It *could* of worked if there was an mdi parent in the project at the time which was not saved down, but thats pretty convoluted to be fair.
0
 
LVL 10

Expert Comment

by:Clif
ID: 17965731
drydenhogg,

You're right, I missed that.  He (or she) couldn't have run it after changing a form to an MDIChild.
0
 

Author Comment

by:ittechie100
ID: 17965733
These are the exact steps that took place:

My existing form that I was trying to print was named form5
I simply changed the MDIChild value to True, clicked
on "Play" if you will" to test it and the form opened via form5.Show (Yes it is greyed out
compared to the rest of my forms icon appearnaces)
The report printed to by default printer just fine. I then stopped
it, saved it, closed and re-opened the project and that is when I started
receiving that error.

At this point, I just need to create a new form? How do you tell it that it is a MDI parent form? I have no more MDI Child forms, only this one.
0
 

Author Comment

by:ittechie100
ID: 17965791
Clif:
I added a MDI form, I set it's property to show children. Run the program
and only the new MDI form appears.

Code is form5.show (Child form), however as i said above only the new MDIform
appears (MDIForm1)
0
 
LVL 10

Expert Comment

by:Clif
ID: 17965814
An MDI form is different than a "normal" form.

Click the (VB IDE) menu option "Project".  You will se the first two items are "Add Form" and "Add MDI Form".  Select the second on to add an MDI Parent to your project.

0
 
LVL 10

Expert Comment

by:Clif
ID: 17965940
Hmm...  Not sure.

It should work (indeed, it works for me).

Not sure what you meant by "I set it's property to show children".  The only property like that is "AutoShow Children", and it defaults to True, so you wouldn't have set it.
0
 

Author Comment

by:ittechie100
ID: 17965971
I'm sorry, for some reason it took a few minutes before it started working. The correct form
is now showing, however it is appearing just as the orginal regular form did and is cutting
thre bottom of the page off when printing. When I first created the MDIChild it printed great, the entire form instead of just what could be seen. Is there any other properties that should be changed to acheive this ?
0
 
LVL 10

Expert Comment

by:Clif
ID: 17966160
I'm not sure what your initial "fix" said.  Perhaps you should re-read it.

I can't think of any properties that one would set in eith a parent or a child form which would fix a form print that is too big for the printer page.

Finally, It's rather odd that you were able to run your test initially.  An MDIChild form cannot exist without an MDIParent form and you should have received an error (as you did later), when you tried to run your app.
0
 

Author Comment

by:ittechie100
ID: 17966191
The problem was that the entire form would only print when the screen resolution was set to 1152X864, Most of my users screen sizes are 1024X768. So they cannot view the entire form, nor print it. The fix I found on the web said that when you create a mdi child that it's properties would display more that it;s parent, and the guy in fact said it corrected his issue. I still have the test page that printed great. I am not sure what happened either, but now I cannot see the entire form ... ??
0
 
LVL 8

Expert Comment

by:drydenhogg
ID: 17966223
Im with clif on this one, cant see how the initial test ran successfully if it was a child.
0
 

Author Comment

by:ittechie100
ID: 17966680
So, In a nutshell, no one thinks this will work ?
0
 
LVL 10

Expert Comment

by:Clif
ID: 17967070
I didn't say it wouldn't work.  I said I couldn't think of how it could work.
0

Featured Post

Technology Partners: 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!

Question has a verified solution.

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

Suggested Solutions

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…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…

733 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