IT tutorials
 
Office
 

Microsoft Access 2010 : Create Custom Forms (part 3) - Adding Subforms

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Product Key Free : Microsoft Office 2019 – Serial Number
2/28/2015 8:30:28 PM

Adding Subforms

So one-to-many relations exists between two tables, you can show the information of “that” and “much” on sides of the relations using a principal form and a subform. For example, the principal form for the relative tables customers and orders could show information on a customer (the “one” side), and the subform could enumerate all the orders which the customer placed (the “many” side).

Suppose that you want to create a principal form which includes all the fields of a table with a subform which includes all the fields of another table. As long as there is only one-to-many relations between the tables already defined in the page of relations, the fastest manner to create the form and its subform is using the tool of form. Click on simply the primary table in the square of navigation, and then on the label of creation, in the group of forms, click the button of form. The tool of form creates and shows a form and a subform, each one which contains all the fields of its table of source.

If you want to create a main form and subform that include only some of the fields in their underlying tables, you can use the Form wizard. To do so:

  1. On the Create tab, in the Forms group, click the Form Wizard button.

  2. On the Form wizard’s first page, in the Tables/Queries list, click the table on which you want to base the form.

  3. In the Available Fields list, double-click the fields you want to include in the main form to move them to the Selected Fields list.

  4. In the Tables/Queries list, click the table on which you want to base the subform.

  5. In the Available Fields list, double-click the fields you want to include in the subform, and then click Next.

    Troubleshooting

    If the relationship between the selected tables has not been defined, Access displays a message. You can click OK to display the Relationships page, where you can define the relationship. You will then need to start the wizard again.

  6. On the wizard’s second page, with the primary table and Form With Subform(s) selected, click Next.

  7. On the third page, select the layout you want, and then click Next.

  8. On the last page, enter the titles you want for your forms, and with Open The Form To View Or Enter Information selected, click Finish.

    The wizard creates and opens the form and subform. You can then use normal techniques to modify the form created by the Form wizard to suit your needs.

    If you have already created a main form and you now want to add a subform to it, you can add a Subform/Subreport control to the form.

    In this exercise, you’ll add a subform to an existing form in Design view, and you’ll then modify its appearance in Layout view.

Set Up

  1. To give yourself space to work, expand the Detail section until it is about 3 inches tall.

  2. On the Design tab, in the Controls group, display the Controls gallery, and at the bottom of the gallery, click the Use Control Wizards button.

    image with no caption

    You want this button to be active (orange).

  3. In the Controls gallery, click the Subform/Subreport button, and then drag a box below the Description label and text box controls in the lower portion of the Detail section.

    image with no caption

    A white unbound control appears in the form, and the SubForm wizard starts.

    Set Up

    The first page of the SubForm wizard.

  4. With Use existing Tables and Queries selected, click Next.

  5. Display the Tables/Queries list, and click Table: Products.

  6. In the Available Fields list, double-click the ProductName, CategoryID, QuantityPerUnit, UnitPrice, and UnitsInStock fields to add them to the Selected Fields list. Then click Next.

    Because there is a relationship between the Products table and the Categories table that is based on the CategoryID field, the wizard selects Choose From A List and indicates the relationship it will use.

    Set Up

    The third page of the SubForm wizard.

    Tip

    If the wizard can’t figure out which fields are related, it selects the Define My Own option and displays list boxes in which you can specify which fields should be related.

  7. With Choose from a list selected, click Next, and then click Finish to accept the suggested name for the subform.

    Access embeds the Products subform in the Categories form. The subform control has its own Form Header, Detail, and Form Footer sections, and can be scrolled independently of the main form.

    Tip

    The name of the subform appears in a label control above the upper-left corner of the subform control.

  8. Above the subform, click the Products subform label, and press the Delete key. Then switch to Form view.

    In this view, the subform looks like a datasheet.

    Tip

    The subform has its own scroll bars and record navigation bar.

    Tip

    This main form and subform are ideal for checking which products are assigned to which categories and for looking up information about the products in a category. But if you want to create a form whose main purpose is data entry, you obviously need to include all the fields in which the database user will need to enter information.

  9. Right-click the subform, point to Subform, and then click Form.

    In this view, the layout of the subform reflects its layout in Design view.

    Tip

    The form layout is not as useful as the datasheet layout.

  10. Repeat step 9 to switch back to Datasheet view. Then, so that you can modify the layout of the subform, switch to Layout view.

  11. Click any cell in the subform, and on the Format tab, in the Font group, click the Font Size arrow, and click 9.

  12. Point to the right border of the Product Name field name, and when the pointer changes to a two-headed arrow, double-click to adjust the column to its widest entry. Then repeat this step for all the other columns.

  13. Widen the subform so that Units in Stock is visible, by dragging the subform’s right border to the right.

    You can now see all the fields of the subform.

    Tip

    Adjusting field widths is often easier in Layout view, where you can see the underlying data from the table.

  14. Switch to Form view, and scroll through several categories by using the record navigation bar for the main form.

    As each category appears at the top of the form, the products in that category are listed in the datasheet in the subform.

  15. Click the First Record button to return to the first category (Bulbs). In the subform, click Bulbs in the Category column to the right of the first product (Magic Lily).

    image with no caption

    The arrow at the right end of the box indicates that this is a combo box.

  16. Click the arrow to display the list of categories, and then change the category to Cacti.

  17. Click the Next Record navigation button to move to the Cacti category.

    image with no caption

    Magic Lily is now included in this category.

  18. Display the Category list for the Magic Lily record, and return it to the Bulbs category.

    We need to prevent people from changing a product’s category.

  19. Switch to Design view, clicking Yes when prompted to save the form and the subform.

  20. In the subform, click the CategoryID combo box control, and then press Delete.

    The CategoryID combo box and its label no longer appear on the form.

  21. Save the form, switch back to Layout view, and then adjust the width of the subform, allowing space for the scroll bar.

  22. Switch to Form view, and scroll through the categories.

    The results are shown here.

    Tip

    You can easily use this form to check the assignments of products to categories.

Clean Up

Close the Categories form, saving your changes. You don’t need the GardenCompany07 database for the next topic, so you can close it.

Different Types of Forms

Most forms facilitate data entry—adding or editing records in one or more tables. However, some forms are more specialized than others, and some serve purposes other than data entry. Here is an overview of the types of forms you can create from the Forms group on the Create tab:

  • Blank form in Design view. Clicking the Form Design button displays a blank design grid where you can design a form from scratch.

  • Blank form in Layout view. Clicking the Blank Form button displays a blank canvas and opens the Field List, from which you can drag fields from the database tables onto the form.

  • Navigation . Clicking the Navigation button displays a gallery of predefined navigation form layouts. You must use a navigation form to provide access to the objects in a Web database, which has no Navigation pane. But navigation forms can be useful for any database.

Clicking the More Forms button displays a gallery of additional types of forms:

  • Multiple Items. This form, sometimes called a Continuous form, allows you to see more than one record at a time on a single form page.

  • Datasheet. This form looks and behaves like a datasheet (table).

  • Split Form . This form provides two synchronized views of the same data, one in a form and the other in a datasheet. This greatly simplifies the process of finding and editing records.

  • Modal Dialog . This form looks and behaves like a dialog box. It has default OK and Cancel buttons. When it is active, nothing else can be done until it is closed.

  • PivotChart . This form displays interactive information in a chart.

  • PivotTable . This form displays an interactive table that uses whatever calculation methods you specify to summarize the data.

 
Others
 
- Microsoft Access 2010 : Create Custom Forms (part 2) - Adding Controls
- Microsoft Access 2010 : Create Custom Forms (part 1) - Modifying Forms Created by Using a Wizard
- Microsoft Word 2010 : Creating Mail Merge Documents - Creating a Data Document
- Microsoft Word 2010 : Creating Mail Merge Documents - Importing Data from Outlook
- Microsoft Word 2010 : Creating Mail Merge Documents - Importing Data from a Database
- Microsoft Word 2010 : Starting the Mail Merge
- Microsoft Visio 2013 : Adding Sophistication to Your Drawings - Understanding and using layers
- Microsoft Visio 2013 : Adding Sophistication to Your Drawings - Inserting pictures
- Microsoft Excel 2010 : Filtering Options (part 3) - Using the Search Function for Grouped Dates, Using Text, Number and Date Special Filters
- Microsoft Excel 2010 : Filtering Options (part 2) - Searching Functions for Listed Items
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Technology FAQ
- Is possible to just to use a wireless router to extend wireless access to wireless access points?
- Ruby - Insert Struct to MySql
- how to find my Symantec pcAnywhere serial number
- About direct X / Open GL issue
- How to determine eclipse version?
- What SAN cert Exchange 2010 for UM, OA?
- How do I populate a SQL Express table from Excel file?
- code for express check out with Paypal.
- Problem with Templated User Control
- ShellExecute SW_HIDE
programming4us programming4us