Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open a form after opening a form

Status
Not open for further replies.

mainit123

Technical User
Jan 24, 2005
25
I have a main form that I use as a start point. Once a checkbox is checked, I successfully open a 2nd form on which is a button. Upon the user clicking that button, I am trying to open a 3rd form called NMember. On the button click action on the 2nd form, I have this code:

Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
NMember.ActiveForm.Enabled = True
NMember.ActiveForm.Activate()
NMember.ActiveForm.Visible = False
'Assume the next line will open the form but it throws an error
NMember.ActiveForm.ShowDialog()
NMember.ActiveForm.Close()
End Sub

But upon clicking the button, I get:
Object reference not set to an instance of an object.

So, it appears I am not truly creating an instance of the NMember form before I tell it to open. The NMember form does exist and up to this point has not been opened.

What am I missing to get this NMember form open upon clicking the button.
Thanks.
 
I was able to see how to solve this by referencing the form ahead of time using DIM.

Take care and this thread can be closed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top