Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Click a button on one form and open another.

Posted on 2000-05-02
6
217 Views
Last Modified: 2010-05-02
Okay, I have two VB 6.0 forms.  When I click on a menu item I want to close one and open the other.  How do I do this?
The first form's name is Form1 and the second form's name is Form2.  The menu item's name is mnuFileOpen.
0
Comment
Question by:zippy221
6 Comments
 
LVL 9

Expert Comment

by:Ruchi
ID: 2770808
Use "Unload Form1"
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2770822
Private Sub mnuFileOpen_Click()
Unload Form1
Form2.Show
End Sub
0
 
LVL 9

Expert Comment

by:Ruchi
ID: 2770831
Try something like this..

Private Sub mnuFileOpen_Click()
Unload Form1
Form2.Show
End Sub
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 32

Accepted Solution

by:
bhess1 earned 10 total points
ID: 2770844
In mnuFileOpen_Click, use code like this:

' If you want to be able to go back to the first form quickly,
'   use the .Hide, otherwise use Unload
'
'Form1.Hide
Unload Form1

Form2.Show   ' loads Form2 if not already loaded

----------------------

Note:
  If you want mnuFileOpen to toggle between the two forms, you can use code like this:

If Form1.Enabled And Form1.Visible Then
  Unload Form1
  Form2.Show
Else   ' assumes one form or the other is shown
  Unload Form2
  Form1.Show
End If
 
0
 
LVL 9

Expert Comment

by:Ruchi
ID: 2770855
Arazsound, you beat me! ;-)
0
 

Author Comment

by:zippy221
ID: 2771190
Thanks-you very much :)
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question