newbie stupidity: opening one form and closing another

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have two forms in my application, the main form (frmMain) and a details
form (frmEditDetails) I have a button on main to open the details form and
close the main form. And the opposite in the details form.

However instead of actually opening one and closing the other it just puts
one over the top. Then when I go from main > details > main I have 3 forms
open.

Using the following code on the Main form:

Dim Details As New frmEditDetails
Details.Show()
Dim Main As New frmMain
Main.Close()

Please someone tell me how I am going wrong.

Thanks
 
Instead of creating a new instance of your main form, create global
variables one for an instance of your main form and another one for an
instance for your frmEditDetails form. This way you don't have
multiple instances of each form. I'd use a module and use the Sub
Main() subroutine to start up your program with something like:

Dim Details as New frmEditDetails
Dim Main as New frmMain

Sub Main()
Application.Start(Main)
End Sub

And then have two separate subroutines within your module and call them
in the repective forms:

Private Sub ShowDetails()
Main.Hide()
Details.Show()
End Sub

Private Sub ShowMain()
Details.Hide()
Main.Show()
End Sub

So then just call ShowMain when they click on the details form and
ShowDetail when they click the button on the main form.

Hope this helps
 
Luke

The own class is called.

Me.

me.close

I hope this helps,

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top