Solved

Add a sub form to a main form in visual basic

Posted on 2004-03-21
6
920 Views
Last Modified: 2006-11-17
Hi,

Can some one explain to me how to add a subform to a main form in visual basic, then in turn link the forms together?

thanks
0
Comment
Question by:kinton
[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
6 Comments
 
LVL 22

Expert Comment

by:cookre
ID: 10644895
Add a new form with Project/Add Form, say Form2.

In Form1, when you want to bring up Form2, do:
Form2.Show

If you don't want Form1 to appear while Form2 is up:
Form1.Hide
Form2.Show

When you're done with Form2, do
Form1.Show

And if you want the cursor to be in a particular field:
Form1.Fieldx.SetFocus
0
 

Expert Comment

by:Fox_What
ID: 10645194
Also, if you want form2 to show and not be able
to click on form1 while it is active you can do:

form2.show vbModal, form1.hwnd
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 10646480
You asked about subforms in VB.  VB doesn't support a true subform.  You can simulate it as shown above.

mlmcc
0
Technology Partners: 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!

 

Expert Comment

by:sreekanth_k77
ID: 10647066
It is so simple to do that.

Create a new form using File --> New Form --> give some name to that form( form2.frm)
then write the following code in button click event.

Private Sub Command1_click()
  form2.show
  form1.hide  ' Write this code if you want to hide the first window.
End Sub
0
 
LVL 2

Accepted Solution

by:
Ivan_Skrinjaric earned 500 total points
ID: 10652013
0
 
LVL 2

Author Comment

by:kinton
ID: 10722422
Sorry about the bad explanation of the question, but against all odds Ivan, you knew exactly what I needed.  Thanks for your help.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ejb example issues 3 84
How to Convert a Quote to an Order in SalesForce 2 152
Adding a countdown to HTA 12 110
Do Wend Macro not working 22 68
This article will show, step by step, how to integrate R code into a R Sweave document
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …

742 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