Opening form as MDI child with a button click from another form

ArchAngel

Newcomer
Joined
May 7, 2005
Messages
7
Dim frm0 as frmMainMdi
Dim frm1 As New frmAsset_new
frm1.MdiParent = frm0
frm1.Show()
Me.Close()


Boys and Girls it is obvious that i am no genius but can anyone explain why i cannot frmAsset_new as a Mdi child under frm0 i. i seem to only to be able to do it using either the menu item click ..... with frm1.Mdiparent = me..... is there a variable i could use that will aloow me do this? thanks guys :confused: :confused: :confused:
 
Do you already have an instance of frmMainMdi open? If so you need to set the MdiParent to be the existing instance, in the code above you are creating a new instance and using that as the MDI parent.
 
Yes i have an instance open......

The MDi parent is already open so i dont need to create a new instance of it. The problem seems to be using variables to reference the mdi parent i.e.

frm1.mdiparent = frm0

if i was writting the code on the frmMainMdi it would not have this problem because i would not use a variable i would use "me" ,,,,, :confused: guys pls get back to me..... i am dieing here.
 
If this from you are opening the from from is a MIDIchild to your MDIForm the solution is easy.

Visual Basic:
Dim frm1 As New frmAsset_new
frm1.MdiParent = me.MdiParent
frm1.Show()
Me.Close()

If not you’ll need a way to store the MDI parent in the form (create a property) and use that one for reference.
 
Back
Top