SlideShare a Scribd company logo
MS ACCESS




SUBFORM SUCCESS



    By Paul Barnett



           1
http://www.access-databases.com/ebooks/subforms ...................................... 2
Beginning Access Database Subforms ............................................................ 3
     What are MS Access subforms?............................................................... 3
     Database subform relationships ............................................................... 5
     Create a subform ...................................................................................... 7
     Manually create a subform...................................................................... 14
     Create multiple subforms ........................................................................ 22
http://www.access-databases.com/ebooks/subforms .................................... 23



                GET THE FULL VERSION OF THIS EBOOK HERE

            http://www.access-databases.com/ebooks/subforms




                                                      2
Beginning Access Database Subforms


What are MS Access subforms?

The best way to think of a subform is a form within another form.

We tend to create our forms to show single pieces of information.

For example, here I have a form which shows a single customer record.




What happens if I want to display related information for this customer?
Supposing the customer has related orders. Right now I have no way of
showing related information within the form.

We show related information by creating a subform and adding it to the main
form.

We can create the subform manually ourselves or use one of the MS Access
wizards to guide us through the steps.




                                      3
Here I have a subform contained within the main form.

The main form details are at the top.

      Customer ID
      Company Name
      City
      Country




The subform holds details of product information sales in each quarter.
Notice there is more than one product. Subforms are ideal for showing
multiple records.

We can also have multiple subforms within a single form.




                                        4
Database subform relationships

MS Access is a relational database. All this means is that we are able to
relate our data together. For example there is a relationship between
customers and orders. Also between students and courses.

Relationships are created via our tables. When creating subforms we need to
look at how we have defined our relationships.

For these examples I am using the Northwind sample database that comes
with MS Access.

Right click at the database window and select relationships




                                       5
The relationship I focus on is between customers and orders.




Notice the primary key of the customers table is CustomerID.

Notice also that this same key is in the orders table.

This tells us that there is a one to many relationship between customers and
orders. One customer can have many orders and each order can belong to
one customer.

This relationship is an ideal candidate for a main subform scenario. The main
form would hold the one side of the relationship – the customer tables details.
The subform would hold the many side of the relationship – the orders table
details.

We show one customer record in the main form and many order details in the
subform.

Looking at the tables we can see that the CustomerID is in both customer and
order tables.




                                        6
Create a subform

Now that I have set up the table relationships it is time to go ahead and create
the main form.

At the database window first click on the forms button.




And then click ‘New’.




The form wizard will then appear.

Select design view.




                                       7
Then select the customers table.




Then click the ok button.



Drag fields from the customers table onto the form.




Hover over the edge of the form with your mouse until you see a cross type
symbol. Hold down the mouse button and then drag the form edge down
slightly in order to make room for the subform. Also drag the sides of the form
out slightly.

Click on the toolbox icon.




                                       8
At the toolbox make sure the wizard button is pressed. It will glow orange
when it is pressed.




From the toolbox select the subform/subreport control.

Drag and drop it onto the form. Keep the mouse button pressed and drag it so
that it fits on the subform.




The wizard will also appear.

Make sure the first option is selected to use existing tables and queries.




                                       9
Click the ‘Next’ button.




Select the orders table from the dropdown box.




I then select a few fields to show on the subform.

It may be worth including CustomerID, although not necessary if you have
defined the links between the tables when creating relationships.




                                      10
Click the ‘Next’ button.

Because I defined the relationship between the customer and order tables,
MS Access makes a guess at how I want to relate the main form and subform.
It has guess correctly in that I will relate by CustomerID. Recall this is how I
related the tables together.




MS Access wants to link the forms together via the CustomerID.

Alternatively, we could also select the define my own option. In this case we
would manually have to relate the main and subform together by choosing the
linking fields.




                                      11
Click the ‘Next’ button to move on.



Now give the subform a name and click the finish button.




                                      12
MS Access has now added the subform to the main form.



Run the form by clicking the button named ‘View’.




Notice the one side of the relationship – Customer - is showing at the top of
the form. This is the main form details.

The customer related orders are showing in the subform.

I have successfully modelled the one customer has many orders relationship.




                                      13
The main form has navigation buttons at the bottom and the subform also has
it’s own.

Use the main form buttons to move through each customer record. The
related orders for each customer will be shown as you move through each
customer record.

Use the subform buttons to move through each subform row.

The main and subform have been successfully created.

Now save the main form.

I name it ‘Customers_Main’




Manually create a subform

We’ve seen how the wizard can be used to step us through creating a
subform.

We are now going to create a subform manually.

Here is my customer record form (Customers_Main) in design view.




                                    14
I have left some blank space for the subform.

We already know that customers are related to orders. I have the customer
record currently showing so now I have to create a subform to hold the related
orders.



At the database window first click on the forms button.




And then click ‘New’.




                                      15
The form wizard will then appear.

Select design view.




I now select the orders table from the dropdown box.




Click the ok button to move on.
From the field list that appears drag and drop the required fields to the form.




                                       16
Double click the small square at the top left of the form to bring up the form
properties.




At the property sheet, click on the ‘All’ tab.




Look for the property called ‘Default View’ and change it to ‘Datasheet’.




                                         17
I now save the form.




Open up the main form in design view and move it so that it is next to the
database window.




Now drag the subform from the database window onto the space in the main
form.




                                      18
Position the subform on the main form. Click on the top of the subform and
look for the small finger symbol at the top left. Hold down the mouse button on
this symbol and drag the subform into position.

Now we need to link both forms together.

Right click the top edge of the subform and select properties.




The two properties we are looking for are the ‘link child fields’ and the ‘link
master fields’.

Link master refers to the linking field in the main form and link child is for the
linking field in the subform.




                                        19
My linking field will be CustomerID in both these properties.

Now run the form.




Clicking on the record selector changes the main form record and shows the
related subform records.

The subform has been created manually and successfully related to the main
form.

I am showing company name in both the main and the subform. This is fine,
but not really necessary.




                                      20
To remove the customer from the subform, go back to form design view,
select the field in the subform and delete it.

Save and run the main form again.

The field will now only show in the main form.




                                      21
Create multiple subforms

We can create more than one subform within a single form.

Here I have a main and a subform.




The customer details containing company name and country are shown in the
main form and I also have two subforms – the first shows order information.
When one of those order lines are clicked the related products are shown in
the second subform.

There is a relationship between the main form details and the first subform.
That relationship is linked via the CustomerID. One customer has many
related orders.

We also have a relationship between orders and products.




                                      22
GET THE FULL VERSION OF THIS EBOOK HERE

        http://www.access-databases.com/ebooks/subforms




For products, ebooks, training and MS Access info, check out the website

                  http://www.access-databases.com/




                   2010 Paul Barnett. All Rights Reserved.
                  No part of this publication may be reprinted
                      or reproduced without permission.




                                      23

More Related Content

DOC
Access4
DOCX
Manual for Fillable Form
DOC
Access3
PDF
Access advanced tutorial
PPT
Access Ch3 Maintaining A Database (Jy)
DOCX
How to use microsoft word
PPTX
Basics of Ms Excel Office Tool
PDF
Detail Views
Access4
Manual for Fillable Form
Access3
Access advanced tutorial
Access Ch3 Maintaining A Database (Jy)
How to use microsoft word
Basics of Ms Excel Office Tool
Detail Views

What's hot (20)

PDF
Inventory Basics
PDF
Work Order Level 1
PPTX
Task 2
PDF
Fomatting Text Tips
PPTX
Gl13 m7-c1-presentation
PDF
Creating Purcahse Orders
DOCX
2580 microsoft excel2010_rtm_wsg_external
DOCX
Cis 407 i lab 2 of 7
DOCX
Word environment
PPTX
Gl13 m7-c3-presentation
PPTX
Gl13 m6-c1-presentation
PPTX
Gl2010 m6 ex1-presentation
DOC
Word 2010
PPTX
Microsoft Environment
PPTX
Week 2 ms word ait
PPT
Access Ch5 Multi Table Forms (Jy)
PPTX
Microsoft Word
PDF
Document generation
PDF
5 saving data to the database
PDF
Access p3
Inventory Basics
Work Order Level 1
Task 2
Fomatting Text Tips
Gl13 m7-c1-presentation
Creating Purcahse Orders
2580 microsoft excel2010_rtm_wsg_external
Cis 407 i lab 2 of 7
Word environment
Gl13 m7-c3-presentation
Gl13 m6-c1-presentation
Gl2010 m6 ex1-presentation
Word 2010
Microsoft Environment
Week 2 ms word ait
Access Ch5 Multi Table Forms (Jy)
Microsoft Word
Document generation
5 saving data to the database
Access p3
Ad

Similar to MS Access Subform Success (20)

PPTX
PDF
Micro Soft Access - Creating Forms
PDF
Access 06
DOCX
CIS 310 ACCESS AssignmentObjective of this assignment is to pr.docx
PDF
MS Access - Create Form.pdf
PPT
HARJOT.ppt
DOCX
Final Project Part 1 (Videos Form) Create this.docx
PPT
05 access howtolookupselect
PPT
HARJOT.ppt gggggggggggggggggggggggggggggggggggggggg
PPT
AIA101.3.Access Reports And Forms
DOCX
A. Lab # BSBA BIS245A-7B. Lab 7 of 7 Database Navigation.docx
PPT
02 access howtobasicforms
PPTX
MS Access teaching powerpoint tasks
PDF
New Perspectives Microsoft Office 365 and Access 2016 Intermediate 1st Editio...
PPTX
Access2013 ch05
PPTX
2 crear formularios training presentation - create forms for a new database
PPTX
4 crear formularios training presentation create forms for a new database-1
PDF
New Perspectives Microsoft Office 365 and Access 2016 Intermediate 1st Editio...
PDF
New Perspectives Microsoft Office 365 and Access 2016 Intermediate 1st Editio...
Micro Soft Access - Creating Forms
Access 06
CIS 310 ACCESS AssignmentObjective of this assignment is to pr.docx
MS Access - Create Form.pdf
HARJOT.ppt
Final Project Part 1 (Videos Form) Create this.docx
05 access howtolookupselect
HARJOT.ppt gggggggggggggggggggggggggggggggggggggggg
AIA101.3.Access Reports And Forms
A. Lab # BSBA BIS245A-7B. Lab 7 of 7 Database Navigation.docx
02 access howtobasicforms
MS Access teaching powerpoint tasks
New Perspectives Microsoft Office 365 and Access 2016 Intermediate 1st Editio...
Access2013 ch05
2 crear formularios training presentation - create forms for a new database
4 crear formularios training presentation create forms for a new database-1
New Perspectives Microsoft Office 365 and Access 2016 Intermediate 1st Editio...
New Perspectives Microsoft Office 365 and Access 2016 Intermediate 1st Editio...
Ad

Recently uploaded (20)

PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PDF
Enhancing emotion recognition model for a student engagement use case through...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
DP Operators-handbook-extract for the Mautical Institute
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PDF
Web App vs Mobile App What Should You Build First.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
project resource management chapter-09.pdf
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
A comparative analysis of optical character recognition models for extracting...
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PPTX
Tartificialntelligence_presentation.pptx
PPTX
1. Introduction to Computer Programming.pptx
PDF
Approach and Philosophy of On baking technology
PPTX
OMC Textile Division Presentation 2021.pptx
PPTX
A Presentation on Artificial Intelligence
Univ-Connecticut-ChatGPT-Presentaion.pdf
Enhancing emotion recognition model for a student engagement use case through...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
DP Operators-handbook-extract for the Mautical Institute
1 - Historical Antecedents, Social Consideration.pdf
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
Web App vs Mobile App What Should You Build First.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
project resource management chapter-09.pdf
NewMind AI Weekly Chronicles - August'25-Week II
Programs and apps: productivity, graphics, security and other tools
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Unlocking AI with Model Context Protocol (MCP)
A comparative analysis of optical character recognition models for extracting...
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
Tartificialntelligence_presentation.pptx
1. Introduction to Computer Programming.pptx
Approach and Philosophy of On baking technology
OMC Textile Division Presentation 2021.pptx
A Presentation on Artificial Intelligence

MS Access Subform Success

  • 1. MS ACCESS SUBFORM SUCCESS By Paul Barnett 1
  • 2. http://www.access-databases.com/ebooks/subforms ...................................... 2 Beginning Access Database Subforms ............................................................ 3 What are MS Access subforms?............................................................... 3 Database subform relationships ............................................................... 5 Create a subform ...................................................................................... 7 Manually create a subform...................................................................... 14 Create multiple subforms ........................................................................ 22 http://www.access-databases.com/ebooks/subforms .................................... 23 GET THE FULL VERSION OF THIS EBOOK HERE http://www.access-databases.com/ebooks/subforms 2
  • 3. Beginning Access Database Subforms What are MS Access subforms? The best way to think of a subform is a form within another form. We tend to create our forms to show single pieces of information. For example, here I have a form which shows a single customer record. What happens if I want to display related information for this customer? Supposing the customer has related orders. Right now I have no way of showing related information within the form. We show related information by creating a subform and adding it to the main form. We can create the subform manually ourselves or use one of the MS Access wizards to guide us through the steps. 3
  • 4. Here I have a subform contained within the main form. The main form details are at the top.  Customer ID  Company Name  City  Country The subform holds details of product information sales in each quarter. Notice there is more than one product. Subforms are ideal for showing multiple records. We can also have multiple subforms within a single form. 4
  • 5. Database subform relationships MS Access is a relational database. All this means is that we are able to relate our data together. For example there is a relationship between customers and orders. Also between students and courses. Relationships are created via our tables. When creating subforms we need to look at how we have defined our relationships. For these examples I am using the Northwind sample database that comes with MS Access. Right click at the database window and select relationships 5
  • 6. The relationship I focus on is between customers and orders. Notice the primary key of the customers table is CustomerID. Notice also that this same key is in the orders table. This tells us that there is a one to many relationship between customers and orders. One customer can have many orders and each order can belong to one customer. This relationship is an ideal candidate for a main subform scenario. The main form would hold the one side of the relationship – the customer tables details. The subform would hold the many side of the relationship – the orders table details. We show one customer record in the main form and many order details in the subform. Looking at the tables we can see that the CustomerID is in both customer and order tables. 6
  • 7. Create a subform Now that I have set up the table relationships it is time to go ahead and create the main form. At the database window first click on the forms button. And then click ‘New’. The form wizard will then appear. Select design view. 7
  • 8. Then select the customers table. Then click the ok button. Drag fields from the customers table onto the form. Hover over the edge of the form with your mouse until you see a cross type symbol. Hold down the mouse button and then drag the form edge down slightly in order to make room for the subform. Also drag the sides of the form out slightly. Click on the toolbox icon. 8
  • 9. At the toolbox make sure the wizard button is pressed. It will glow orange when it is pressed. From the toolbox select the subform/subreport control. Drag and drop it onto the form. Keep the mouse button pressed and drag it so that it fits on the subform. The wizard will also appear. Make sure the first option is selected to use existing tables and queries. 9
  • 10. Click the ‘Next’ button. Select the orders table from the dropdown box. I then select a few fields to show on the subform. It may be worth including CustomerID, although not necessary if you have defined the links between the tables when creating relationships. 10
  • 11. Click the ‘Next’ button. Because I defined the relationship between the customer and order tables, MS Access makes a guess at how I want to relate the main form and subform. It has guess correctly in that I will relate by CustomerID. Recall this is how I related the tables together. MS Access wants to link the forms together via the CustomerID. Alternatively, we could also select the define my own option. In this case we would manually have to relate the main and subform together by choosing the linking fields. 11
  • 12. Click the ‘Next’ button to move on. Now give the subform a name and click the finish button. 12
  • 13. MS Access has now added the subform to the main form. Run the form by clicking the button named ‘View’. Notice the one side of the relationship – Customer - is showing at the top of the form. This is the main form details. The customer related orders are showing in the subform. I have successfully modelled the one customer has many orders relationship. 13
  • 14. The main form has navigation buttons at the bottom and the subform also has it’s own. Use the main form buttons to move through each customer record. The related orders for each customer will be shown as you move through each customer record. Use the subform buttons to move through each subform row. The main and subform have been successfully created. Now save the main form. I name it ‘Customers_Main’ Manually create a subform We’ve seen how the wizard can be used to step us through creating a subform. We are now going to create a subform manually. Here is my customer record form (Customers_Main) in design view. 14
  • 15. I have left some blank space for the subform. We already know that customers are related to orders. I have the customer record currently showing so now I have to create a subform to hold the related orders. At the database window first click on the forms button. And then click ‘New’. 15
  • 16. The form wizard will then appear. Select design view. I now select the orders table from the dropdown box. Click the ok button to move on. From the field list that appears drag and drop the required fields to the form. 16
  • 17. Double click the small square at the top left of the form to bring up the form properties. At the property sheet, click on the ‘All’ tab. Look for the property called ‘Default View’ and change it to ‘Datasheet’. 17
  • 18. I now save the form. Open up the main form in design view and move it so that it is next to the database window. Now drag the subform from the database window onto the space in the main form. 18
  • 19. Position the subform on the main form. Click on the top of the subform and look for the small finger symbol at the top left. Hold down the mouse button on this symbol and drag the subform into position. Now we need to link both forms together. Right click the top edge of the subform and select properties. The two properties we are looking for are the ‘link child fields’ and the ‘link master fields’. Link master refers to the linking field in the main form and link child is for the linking field in the subform. 19
  • 20. My linking field will be CustomerID in both these properties. Now run the form. Clicking on the record selector changes the main form record and shows the related subform records. The subform has been created manually and successfully related to the main form. I am showing company name in both the main and the subform. This is fine, but not really necessary. 20
  • 21. To remove the customer from the subform, go back to form design view, select the field in the subform and delete it. Save and run the main form again. The field will now only show in the main form. 21
  • 22. Create multiple subforms We can create more than one subform within a single form. Here I have a main and a subform. The customer details containing company name and country are shown in the main form and I also have two subforms – the first shows order information. When one of those order lines are clicked the related products are shown in the second subform. There is a relationship between the main form details and the first subform. That relationship is linked via the CustomerID. One customer has many related orders. We also have a relationship between orders and products. 22
  • 23. GET THE FULL VERSION OF THIS EBOOK HERE http://www.access-databases.com/ebooks/subforms For products, ebooks, training and MS Access info, check out the website http://www.access-databases.com/  2010 Paul Barnett. All Rights Reserved. No part of this publication may be reprinted or reproduced without permission. 23