Is it possible sub-forms in Visual Basic

Posted on 2012-08-29
Last Modified: 2012-09-17
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
Question by:jonsuns7
    LVL 40

    Assisted Solution

    by:Jacques Bourgeois (James Burger)
    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.
    LVL 83

    Accepted Solution

    LVL 26

    Assisted Solution

    by:Alan Warren
    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)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
    Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now