• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 554
  • 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)PresidentCommented:
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 WarrenApplications DeveloperCommented:
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)
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: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

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