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

Is it possible sub-forms in Visual Basic

I was wondering if anyone could answer this question for me. I wanted to know if there was a way to create a form/sub-form setup in Visual Basic.

This would be similar to what is available in MS Access, where a parent table is referenced in the main form and a child table would be referenced in a sub-form. This setup on a form would maintain the parent-child table relationship.

Thank you so much
3 Solutions
Jacques Bourgeois (James Burger)Commented:
If you look under the table, a Form is a Control (the Form class inherits from Control). You can thus use a Form anywhere a Control is used.

You might be more interested in a UserControl however. It's been designed just for that type of job and is easier to integrate into a Form. It is a surface that you use just as you do a Form. But it has no border, title bar and the such. You create one through the same menu or window that you use to create forms. You put controls on it, program them as if they were on a form and compile. The result will be a new Control in the ToolBox.

UserControls are usually preferable because they take up less ressources. But in some situations, a Form as more features and can make things simpler to code.

You will have to maintain the parent-child relationship through your code however. This is not complex to do. Since the UserControl is contained into the form, it sees everything in the form.
Alan WarrenCommented:
Yes, absolutely!
If you put a repeater into a formview template then another formview along with it's sqldatasource in the repeater, the sqldatasource in the repeater having a control parameter(LinkChild) linking to a control in the parent form(LinkMaster), you will have sub-forms coming out of the woodwork!

Same like the LinkChild and LinkMaster fields in MsAccess subforms.

More info?

Alan ";0)

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

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