0

Hey guys,

I have simple menu item that opens a form upon click.
The problem is menu item opens a new instance of the same form every time I click on it.
I want it so when the form assigned to the menu item is open then the code will ignore the request to open another form.
Please help

Private Sub miReportProblem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles miReportProblem.Click


            Dim NewMDIChild As New frmReportProblem()
            NewMDIChild.MdiParent = Me
            NewMDIChild.Show()

    End Sub
3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by bluehangook629
0

Hey guys,

I have simple menu item that opens a form upon click.
The problem is menu item opens a new instance of the same form every time I click on it.
I want it so when the form assigned to the menu item is open then the code will ignore the request to open another form.
Please help

Private Sub miReportProblem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles miReportProblem.Click


            Dim NewMDIChild As New frmReportProblem()
            NewMDIChild.MdiParent = Me
            NewMDIChild.Show()

    End Sub

http://support.microsoft.com/kb/210248

1

Do it this way:

Private NewMDIChild As frmReportProblem
Private Sub miReportProblem_Click(sender As System.Object, e As System.EventArgs)
	If NewMDIChild Is Nothing Then
		NewMDIChild = New frmReportProblem()
		NewMDIChild.MdiParent = Me
		NewMDIChild.Show()
	End If
End Sub
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.