Open form, close form, open form = disposed object exception 
Author Message
 Open form, close form, open form = disposed object exception

On a MDI document interface, when I go to draw my own Help->About dialog, I
run the following:

Public g_frmAbout As New frmAbout()
g_frmAbout.MdiParent = Me
g_frmAbout.Show()
g_frmAbout.Activate()

Then go about closing the form by clicking the x in the corner.

Then go to open the Help->About in order to open it again and it breaks on
the following line:

g_frmAbout.Show()

The error is: "Cannot access a disposed object"

Help :)

-Chris



Sun, 26 Jun 2005 07:46:05 GMT  
 Open form, close form, open form = disposed object exception

Having public tells me that your declaration is outside of the
procedure.This creates an object in the scope of your current class.  What
you should do is declare your object variable first then create an instance
within your procedure only. Check to see an instance doesn't already exist
then check to make sure that the form isn't already visible before opening
another.

Basically the close method does not destroy the object your form is
generated from but the UI only

 Public g_frmAbout As frmAbout()

procedure(sub or function)
If Not IsNothing(g_frmAbout) Then

If g_frmAbout.Visible = True Then Exit Sub

End If

g_frmAbout = New g_frmAbout

g_frmAbout.MdiParent = Me

g_frmAbout.Show()

g_frmAbout.Activate()

end procedure

Cheers

Randy


Quote:
> On a MDI document interface, when I go to draw my own Help->About dialog,
I
> run the following:

> Public g_frmAbout As New frmAbout()
> g_frmAbout.MdiParent = Me
> g_frmAbout.Show()
> g_frmAbout.Activate()

> Then go about closing the form by clicking the x in the corner.

> Then go to open the Help->About in order to open it again and it breaks on
> the following line:

> g_frmAbout.Show()

> The error is: "Cannot access a disposed object"

> Help :)

> -Chris



Sun, 26 Jun 2005 13:34:22 GMT  
 Open form, close form, open form = disposed object exception
Try this way.

Every Time you want to open a form take this !!

If LogWindow Is Nothing OrElse LogWindow.IsDisposed Then LogWindow = New
LogDialog()

LogWindow.Show()



Quote:
> On a MDI document interface, when I go to draw my own Help->About dialog,
I
> run the following:

> Public g_frmAbout As New frmAbout()
> g_frmAbout.MdiParent = Me
> g_frmAbout.Show()
> g_frmAbout.Activate()

> Then go about closing the form by clicking the x in the corner.

> Then go to open the Help->About in order to open it again and it breaks on
> the following line:

> g_frmAbout.Show()

> The error is: "Cannot access a disposed object"

> Help :)

> -Chris



Sun, 26 Jun 2005 16:51:43 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Form.Close or Form.Dispose

2. form.close or form.dispose?

3. Time Delay, close current form, open new form

4. Opening a form when another form is opened

5. Forms Collection: Using it to Open Forms by Passing the Form Name as a String Variable

6. open form from other form

7. can a form on item_open find out what view the form was opened

8. Form name is Text, how do I open form

9. i can't open a inherited form with form editor (beta 2)

10. Can't open form in Form View...

11. opening a form in a form

12. Opening new forms from form in Access

 

 
Powered by phpBB® Forum Software