Adding a form to a Collection, in the MDI Environment

FunBunny
09-06-2003, 10:03 PM
I need to be able to create a simple application in the MDI Environment using Collections, definitely the built-in collection forms. I have a main form, the MDI Parent, and I've created a child form, simply called Form1 with MDIChild set to 'True'. Based on what I've learned, I should be able to simple add a new form by using the command:

Forms.Add Form1

But I get a type mismatch error.

I've tried declaring a variable as a collection and setting it to Forms, but that doesn't work either.

I'm supposed to be able to create an application that will create a new form based on Form1, every time the user selects 'New' from the menu item I created. I can't even create one. Please help? Thanks.

I've attached zipped up my project, its very small, so that anybody who wants to see it can. Please let me know if this is not appropriate.

TIA

FunBunny

BKSwindell
09-06-2003, 10:44 PM
I need to be able to create a simple application in the MDI Environment using Collections, definitely the built-in collection forms. I have a main form, the MDI Parent, and I've created a child form, simply called Form1 with MDIChild set to 'True'. Based on what I've learned, I should be able to simple add a new form by using the command:

Forms.Add Form1

But I get a type mismatch error.

I've tried declaring a variable as a collection and setting it to Forms, but that doesn't work either.

I'm supposed to be able to create an application that will create a new form based on Form1, every time the user selects 'New' from the menu item I created. I can't even create one. Please help? Thanks.

I've attached zipped up my project, its very small, so that anybody who wants to see it can. Please let me know if this is not appropriate.

TIA

FunBunny

Try This:'Assuming frmDocument is a premade form with the MDI Child property set to True
Sub LoadNewDoc()
Static lDocumentCount As Long
Dim frmD As frmDocument
lDocumentCount = lDocumentCount + 1
Set frmD = New frmDocument
frmD.Caption = "Document " & lDocumentCount
frmD.Show
End Sub

FunBunny
09-06-2003, 11:06 PM
Thanks BK. That got me going in the right direction. I ended up using the code below. It gets run every time a user clicks 'New'. You'll see your inspiration in it. It will now create multiple instances of the existing, but unloaded form. Now I've got more work to do with it. You and everybody else may be hearing from me more that once this evening.

Private Sub mnuNew_Click()
' Create local variables
Dim intFormCtr As Integer 'to increment added forms
Dim frmNewChild As New Form1

'increment intFromCtr
intFormCtr = intFormCtr + 1

'Show Child forms
frmNewChild.Show

'show count of forms load in Forms Collection
'MsgBox ("Current number of forms load = " & Forms.Count)

End Sub

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum