• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 952
  • Last Modified:

Add a sub form to a main form in visual basic

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
kinton
Asked:
kinton
1 Solution
 
cookreCommented:
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
 
Fox_WhatCommented:
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
 
mlmccCommented:
You asked about subforms in VB.  VB doesn't support a true subform.  You can simulate it as shown above.

mlmcc
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
sreekanth_k77Commented:
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
 
Ivan_SkrinjaricCommented:
0
 
kintonAuthor Commented:
Sorry about the bad explanation of the question, but against all odds Ivan, you knew exactly what I needed.  Thanks for your help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now