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

Runtime error 366 "No MDI form available to load

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
ittechie100
Asked:
ittechie100
  • 7
  • 5
  • 3
1 Solution
 
ClifCommented:
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
 
drydenhoggCommented:
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
 
ClifCommented:
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
Industry Leaders: 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!

 
drydenhoggCommented:
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
 
ClifCommented:
drydenhogg,

You're right, I missed that.  He (or she) couldn't have run it after changing a form to an MDIChild.
0
 
ittechie100Author Commented:
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
 
ittechie100Author Commented:
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
 
ClifCommented:
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
 
ClifCommented:
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
 
ittechie100Author Commented:
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
 
ClifCommented:
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
 
ittechie100Author Commented:
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
 
drydenhoggCommented:
Im with clif on this one, cant see how the initial test ran successfully if it was a child.
0
 
ittechie100Author Commented:
So, In a nutshell, no one thinks this will work ?
0
 
ClifCommented:
I didn't say it wouldn't work.  I said I couldn't think of how it could work.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 7
  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now