I tried this out myself. Let me post all the code I used and you can
compare.
MDI Declarations, outside any sub:
Public f1 As Form1
Public f2 As Form2
MDI Load event:
f1 = New Form1
f1.MdiParent = Me
f1.Show()
In a button click event in form1,
CType(Me.MdiParent, MAINMDI).f2 = New Form2
CType(Me.MdiParent, MAINMDI).f2.MdiParent = Me.MdiParent
CType(Me.MdiParent, MAINMDI).f2.Show()
Me.Close()
Compare well?
HTH
Altaf
--------------------------------------------------------------------------------
All that glitters has a high refractive index.
www.mendhak.com
"Vinay Kant" <(E-Mail Removed)> wrote in message
news:7A653D44-F7A1-47D6-AEFF-(E-Mail Removed)...
> Altaf,
> I used a Dim to declare that, i have event tried declaring it as public,
> still the same problem. Code just breaks and takes me to the MDI Parent
> class
> while debugging.
> Problem persists. Any other suggestions.
>
> Thanks,
> Vinay kant
>
> "S.M. Altaf [MVP]" wrote:
>
>> I don't know how you've declared lForm, but you should declare it as
>> public
>> in your MDI form, then
>>
>> CType(Me.MdiParent, MAINMDI).lForm = New TestForm
>>
>> CType(Me.MdiParent, MAINMDI).lForm.Show()
>>
>> Me.Close()
>>
>>
>>
>>
>>
>> --------------------------------------------------------------------------------
>> All that glitters has a high refractive index.
>> www.mendhak.com
>>
>>
>> "Vinay Kant" <(E-Mail Removed)> wrote in message
>> news:0A39849F-D463-48AD-B8F0-(E-Mail Removed)...
>> > Hey All,
>> > What we are trying to achieve is, when Selected value changed event is
>> > fired
>> > for a combo box, then we are trying to close the current form and
>> > display
>> > the
>> > new form. The forms are mdi child of a MDI form named as MasterForm.
>> >
>> > The code being used to close the current form and open the new form is
>> > as
>> > follows:
>> >
>> > lForm = new TestForm
>> > lForm.MdiParent = Me.MdiParent
>> > lForm.Show()
>> > Me.Close()
>> >
>> > Problem is on Selected value changed event, we get an unhandled
>> > exception,
>> > Object reference not set to an instance of Object. I debugged and found
>> > that
>> > while closing the current form, its throwing the error.
>> >
>> > Can anyone please suggest this behaviour, is it a known issue.
>> >
>> > Thanks,
>> >
>> > Vinay Kant
>> >
>>
>>
>>