Link to home
Start Free TrialLog in
Avatar of DarkAge
DarkAge

asked on

Load all forms

I have an MDI form and about 70 forms in it (Yes i know i'm crqzy) the story is that i need to load all of them at start up or a method to refare to them even when they are not loaded, The Forms collection contain only loaded forms and i realy dont want to start typing 70 lines of load X, Load Y, Load M etc.
I need an answer ASAP, Please my job depends on it, Thank you.
Avatar of waty
waty
Flag of Belgium image

One solution is naming your forms mdiChild(0) ... mdiChild(69)
and do
 for  nI = 0 to 69
    Load mdiChild(nI)
 Next
Avatar of mark2150
mark2150

I think that "70 lines of load X, Load Y, Load M" may be the only way out. How can the app know the list of forms that you want until it's told?

You might be able to make a data structure in a disk file or something with the list of forms to load, but that is cumbersome. You CAN load a form from a variable.

'Form1 Code:
Private Sub Form_Load()
    Text1.Text = "Form2"
End Sub

Private Sub Command1_Click()
    LoadFormByName Text1.Text
End Sub

Private Sub LoadFormByName(sFormName As String)
    Dim NewForm As Form
    Set NewForm = Forms.Add(sFormName)
    NewForm.Show
End Sub

You still have the problem of generating the list of forms to load. Maybe you could make a copy of the .VBP file and use that?

M
We normaly use a the form.count method to unload all forms.
I do suppose, that you could use it to load them all.


He can't use form.count as the count is zero/one since they haven't been loaded yet!
Avatar of DarkAge

ASKER

I cant give a form name with ( ), Sorry
Avatar of DarkAge

ASKER

Hey mark2150, U'r answer is the one and it's wounderfull thanks, But it looks like it's locked for the other one who was mistaken, I want to grant you the points, You realy saved my neck man, thanks - How can i unlock it and give you the points?

ASKER CERTIFIED SOLUTION
Avatar of mark2150
mark2150

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DarkAge

ASKER

Ten Four, Out.