By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,881 Members | 1,393 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,881 IT Pros & Developers. It's quick & easy.

Accessing form from module

P: n/a
dear sir

In my window application i have the MDI form MainMDI and child form form1 adn module as MainModule
In my MainMDI Parent form i have one toolbar i.e. tbraction. I am trying to show the toolbar when i am displaying form1 (child form) . when i close the child form i want it to be hiddeni.e. invisible

i wrote the code in MainModule as

Friend Module MainModule

Friend frmMDI As MainMDI

End Module

and in the child form closed event i wrote:
Private Sub form1_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed
On Error GoTo errHandler

frmMDI.tbrAction.Visible = False
Exit Sub

If Err.Number <> 0 Then
MsgBox(Err.Number & vbCrLf & Err.Description)
End If
but while accessing the code it give me error

Error 91
Object reference not set to an instance of the object
Please let me know how to solve this error.

Jul 21 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a

Which object is throwing that error?

if it's Friend frmMDI As MainMDI then you need to set it to something.

Friend frmMDI As New MainMDI?

I'm not too sure since I never liked using modules, but too all their own. You might need to take time in examining it.

Lastly, I see On Error GoTo.. That made my skin crawl.

' code
Catch exp As Exception
End Try

^ that's better means of error handling.
Jul 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.