?
Solved

Multiple forms

Posted on 2002-06-07
12
Medium Priority
?
143 Views
Last Modified: 2010-05-02
I have 3 forms in my project.
Form 1 is the main form and gets displayed with application starts. It has a Menu Item to show form2. Form2 has a command button to show form3.  Whenever a form is shown, I do not want any other
form shown.

On form3 there is a text box that will update a list box on form2.

This could be generalized for any number of forms.

How can I do this?

0
Comment
Question by:pentomino
[X]
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
  • 5
  • 4
  • 3
12 Comments
 
LVL 4

Expert Comment

by:gencross
ID: 7063207
If I understand correctly you can use the form.hide method to hide the form when the other is loaded.  The form is still loaded in memory, but not visible.

Hope this helps
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 7063233
To update something on Form2 from Form3, simply reference the object explicitly:

' code in form3:
Form2.Text1.Text = "I added this from Form3"

To show Form2 from Form1:

' code in form1:
private sub Command1_Click()
  Form2.Show ' vbModal (optional)
end sub

' code in form2:
private sub Command1_Click()
  Form3.Show ' vbModal
end sub
0
 
LVL 22

Accepted Solution

by:
rspahitz earned 200 total points
ID: 7063242
Sorry...

'from form1:
private sub Menu1_Click()
  me.hide
  Form2.Show
end sub

'from form2:
private sub Form_Unload()
  Form1.Show
end sub

Private sub Command1_Click()
  me.hide
  Form3.Show
end sub

' from form3:
private sub Form_Unload()
  Form2.Show
end sub

private sub Text1_LostFocus()
  Form2.List1.AddItem Text1.Text
end sub
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:pentomino
ID: 7063312
rspahitz

I created a project and coded exactly as you described.
Form1 does not dissapear!


Pentomino
0
 
LVL 4

Expert Comment

by:gencross
ID: 7063321
I have tried the code and it works fine for me.
0
 
LVL 1

Author Comment

by:pentomino
ID: 7063367
gencross

I changed the menu item to a command button and I still get the same results.

Are you sure from1 is not hiding under form2?
0
 
LVL 4

Expert Comment

by:gencross
ID: 7063375
Are you sure you did not put Form1.show in the Form_Load event of form 2?  It belongs in the Form_Unload event of Form2

This would cause form1 to remain visible.
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 7063439
Post your code from form 1's menu and we'll investigate.

If you want, you can be explicit by replaceing "me" with "form1":

private sub Menu1_Click()
 Form1.hide
 Form2.Show
end sub
0
 
LVL 1

Author Comment

by:pentomino
ID: 7063606
rspahitz

Code has been deleted..  thanks for trying to help, I think this has been solved.
something to do about the Unload_Form subroutine..

Pentomino


0
 
LVL 22

Expert Comment

by:rspahitz
ID: 7063614
Can you be more specific?
How did you solve it?  Which of the above comments helped?
0
 
LVL 1

Author Comment

by:pentomino
ID: 7063690
rspahitz

I think it had something to do with the Form_Unload routine.
I did not have one in the early test application.

If you want to examine this more... I will try to reconstruct the sample that did not work.


Thanks again for your comments and help.
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 7067677
As long as you got it working, great.  If not, drop another comment here and I'll see what I can do.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…
Suggested Courses
Course of the Month14 days, 18 hours left to enroll

771 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