The article explains the uses of Subforms in multiple controls on multiple forms and how to acquire information using subforms.
Subforms are useful tools in dealing with relational data in tables in Microsoft Access. They allow users to control multiple forms or Queries using a many side relationship. A subform, as the name suggests is part of a main form, and is a part of it. The article will explore the uses and functioning of Subforms in MS Access.
Subforms in MS Access
Subforms are the forms enclosed in main form (primary or parent form) and are useful in displaying data from different tables having one-to-many relationships, where Mainform shows the one side of the relationship and Subforms show the many side.
For example, ‘Students’ can be a form displaying their names and addresses, and it can have a subform, ‘Grades’ displaying the CGPA scores and semesters cleared. With the help of Subforms, we can make a reference from Students form to Grades Subform. We need to use ‘dot’ as a separator, and one reference to the Last name control on mainform (Students) can be made as:
It’s worth consideration that the area on a form containing a subform is also a control, having a ‘.form’ property which has a reference to the form it holds. Users can find it in Design view. If users wish to make references to the subforms, they must remember to include ‘.form’.
Like this: Forms.Students.Grades.Form.Credits
Here, Students – parent form name,
.form – Included as per the rule,
Grades – control name holding the subform,
Credits – Control on the subform.
Control is like an interface between the two forms, parent and subform, and it allows the linking of displayed data in the control to the main form data.
More on Subforms
If you wish to create both the forms, and link the subform to mainform, one easy way is to use the Form Wizard. To do so, you can go to Create tab in the ‘Forms’ group and click Form Wizard. There you can select a Query and double click the fields which you wish to include in the table. This was for the one-side relationship, follow the same steps for many-side relationship by selecting another table from the list. As you click Next, the form wizard will ask, ‘How do you want to view the data’, and then after selecting the one side table of the one to many relationship, proceed to the selection of Form with Subform and click Next. After formatting and tabulating, click Finish.
Thus, Access will display two forms, one from the parent form containing the control and other one for the subform.
Access also provides the option of Subform Wizard which is helpful if you wish to add more than one sub forms to some existing mainform. Subform Wizard can be accessed from the Controls group in Design tab.
MS Access also allows the creation of Subform by dragging one form onto another and also allows design changes which can be accessed from the Design tab in Tools Group.
While Access can easily be counted amongst the most widely used database applications in the small business segment, it is susceptible to several errors. So if you use Access for professional work or in your business, be sure get hold of a tool to repair mdb files in case of data corruption.
Vivian Stevens is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including sql repair and excel recovery software products. For more information visit www.datanumen.com