My mistake on the first line I gave you. You need to set the child form holder variable to Nothing by default.
Dim childForm As System.Windows.Forms.Form = Nothing
You need to replace "MyChildFormType" with the class type of your child forms. You mention an employee form and a product form, so you could have something like this:
childForm = New frmEmployee()
or
childForm = New frmProduct()
Note that I changed the line to use the "childForm" variable as the assigned to variable. The point is that you always create the new form instance in the same variable (childForm) so you can check it to see if there is already one open. Otherwise you'd have lots of test testing each variable for each form type.
The easiest way to solve this is to create a method that opens your forms for you. It can be responsible for handling the open form check and possible closing of it before opening the new form. Something like this should do the trick:
Code:
'Put this at the top of your parent form class code
'This is the placeholder for the single open child form
'Defaults to Nothing as no form is open by default
Private _childForm As System.Windows.Forms.Form = Nothing
Private Sub OpenNewForm(newForm As System.Windows.Forms.Form)
If _childForm IsNot Nothing Then
_childForm.Close()
End If
_childForm = newForm
_childForm.Show()
End Sub
'Then where ever you need to open the forms (such as menu actions)
OpenNewForm(New frmEmployee())
OpenNewForm(New frmProduct())
etc...
-Peter