SlideShare a Scribd company logo
1 of 23
Download to read offline
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

What's hot

Inventory Basics
Inventory BasicsInventory Basics
Inventory BasicsEMAINT
 
Work Order Level 1
Work Order Level 1Work Order Level 1
Work Order Level 1EMAINT
 
Fomatting Text Tips
Fomatting Text TipsFomatting Text Tips
Fomatting Text TipsEMAINT
 
Gl13 m7-c1-presentation
Gl13 m7-c1-presentationGl13 m7-c1-presentation
Gl13 m7-c1-presentationTracie King
 
Creating Purcahse Orders
Creating Purcahse OrdersCreating Purcahse Orders
Creating Purcahse OrdersEMAINT
 
2580 microsoft excel2010_rtm_wsg_external
2580 microsoft excel2010_rtm_wsg_external2580 microsoft excel2010_rtm_wsg_external
2580 microsoft excel2010_rtm_wsg_externalBrittanyShatia
 
Cis 407 i lab 2 of 7
Cis 407 i lab 2 of 7Cis 407 i lab 2 of 7
Cis 407 i lab 2 of 7helpido9
 
Gl13 m7-c3-presentation
Gl13 m7-c3-presentationGl13 m7-c3-presentation
Gl13 m7-c3-presentationTracie King
 
Gl13 m6-c1-presentation
Gl13 m6-c1-presentationGl13 m6-c1-presentation
Gl13 m6-c1-presentationTracie King
 
Gl2010 m6 ex1-presentation
Gl2010 m6 ex1-presentationGl2010 m6 ex1-presentation
Gl2010 m6 ex1-presentationTracie King
 
Word 2010
Word 2010Word 2010
Word 2010dmcrory
 
Microsoft Environment
Microsoft EnvironmentMicrosoft Environment
Microsoft EnvironmentVernie Gamit
 
Access Ch5 Multi Table Forms (Jy)
Access Ch5   Multi Table Forms (Jy)Access Ch5   Multi Table Forms (Jy)
Access Ch5 Multi Table Forms (Jy)Chun Hoi Lam
 
5 saving data to the database
5 saving data to the database5 saving data to the database
5 saving data to the databasepvenky1578
 

What's hot (20)

Inventory Basics
Inventory BasicsInventory Basics
Inventory Basics
 
Work Order Level 1
Work Order Level 1Work Order Level 1
Work Order Level 1
 
Task 2
Task 2Task 2
Task 2
 
Fomatting Text Tips
Fomatting Text TipsFomatting Text Tips
Fomatting Text Tips
 
Gl13 m7-c1-presentation
Gl13 m7-c1-presentationGl13 m7-c1-presentation
Gl13 m7-c1-presentation
 
Creating Purcahse Orders
Creating Purcahse OrdersCreating Purcahse Orders
Creating Purcahse Orders
 
2580 microsoft excel2010_rtm_wsg_external
2580 microsoft excel2010_rtm_wsg_external2580 microsoft excel2010_rtm_wsg_external
2580 microsoft excel2010_rtm_wsg_external
 
Cis 407 i lab 2 of 7
Cis 407 i lab 2 of 7Cis 407 i lab 2 of 7
Cis 407 i lab 2 of 7
 
Word environment
Word environmentWord environment
Word environment
 
Gl13 m7-c3-presentation
Gl13 m7-c3-presentationGl13 m7-c3-presentation
Gl13 m7-c3-presentation
 
Gl13 m6-c1-presentation
Gl13 m6-c1-presentationGl13 m6-c1-presentation
Gl13 m6-c1-presentation
 
Gl2010 m6 ex1-presentation
Gl2010 m6 ex1-presentationGl2010 m6 ex1-presentation
Gl2010 m6 ex1-presentation
 
Word 2010
Word 2010Word 2010
Word 2010
 
Microsoft Environment
Microsoft EnvironmentMicrosoft Environment
Microsoft Environment
 
Week 2 ms word ait
Week 2 ms word   aitWeek 2 ms word   ait
Week 2 ms word ait
 
Access Ch5 Multi Table Forms (Jy)
Access Ch5   Multi Table Forms (Jy)Access Ch5   Multi Table Forms (Jy)
Access Ch5 Multi Table Forms (Jy)
 
Microsoft Word
Microsoft WordMicrosoft Word
Microsoft Word
 
Document generation
Document generationDocument generation
Document generation
 
5 saving data to the database
5 saving data to the database5 saving data to the database
5 saving data to the database
 
Access p3
Access p3Access p3
Access p3
 

Similar to MS Access Subform Success

MS Access - Create Form.pdf
MS Access - Create Form.pdfMS Access - Create Form.pdf
MS Access - Create Form.pdfSRReliability
 
CIS 310 ACCESS AssignmentObjective of this assignment is to pr.docx
CIS 310 ACCESS AssignmentObjective of this assignment is to pr.docxCIS 310 ACCESS AssignmentObjective of this assignment is to pr.docx
CIS 310 ACCESS AssignmentObjective of this assignment is to pr.docxclarebernice
 
Micro Soft Access - Creating Forms
Micro Soft Access - Creating FormsMicro Soft Access - Creating Forms
Micro Soft Access - Creating FormsFaHaD .H. NooR
 
Lead Management in SugarCRM Series: Adding Leads and Opportunities
Lead Management in SugarCRM Series: Adding Leads and OpportunitiesLead Management in SugarCRM Series: Adding Leads and Opportunities
Lead Management in SugarCRM Series: Adding Leads and OpportunitiesAtcore Systems
 
A. Lab # BSBA BIS245A-7B. Lab 7 of 7 Database Navigation.docx
A. Lab #  BSBA BIS245A-7B. Lab 7 of 7  Database Navigation.docxA. Lab #  BSBA BIS245A-7B. Lab 7 of 7  Database Navigation.docx
A. Lab # BSBA BIS245A-7B. Lab 7 of 7 Database Navigation.docxransayo
 
183201020 sales force-class-5
183201020 sales force-class-5183201020 sales force-class-5
183201020 sales force-class-5Amit Sharma
 
Lesson Five Building Table Relationships
Lesson Five   Building Table RelationshipsLesson Five   Building Table Relationships
Lesson Five Building Table Relationshipsguevarra_2000
 
acct accounting Table Lab.pdf
acct accounting Table Lab.pdfacct accounting Table Lab.pdf
acct accounting Table Lab.pdfbkbk37
 
CIS 3100 - Database Design and ImplementationProducts on Sale Da.docx
CIS 3100 - Database Design and ImplementationProducts on Sale Da.docxCIS 3100 - Database Design and ImplementationProducts on Sale Da.docx
CIS 3100 - Database Design and ImplementationProducts on Sale Da.docxmccormicknadine86
 
Computer Assignment #2 Company Database GuideCustomer Table Da.docx
Computer Assignment #2 Company Database GuideCustomer Table Da.docxComputer Assignment #2 Company Database GuideCustomer Table Da.docx
Computer Assignment #2 Company Database GuideCustomer Table Da.docxzollyjenkins
 
Form Design: Best Practices to Improve Conversions
Form Design: Best Practices to Improve ConversionsForm Design: Best Practices to Improve Conversions
Form Design: Best Practices to Improve ConversionsLauren Martin
 
Power BI Data Modeling.pdf
Power BI Data Modeling.pdfPower BI Data Modeling.pdf
Power BI Data Modeling.pdfVishnuGone
 
- Database Design and ImplementationProducts on Sale Database fo.docx
- Database Design and ImplementationProducts on Sale Database fo.docx- Database Design and ImplementationProducts on Sale Database fo.docx
- Database Design and ImplementationProducts on Sale Database fo.docxgertrudebellgrove
 
Microsoft Access 2010 - a jargon free guide
Microsoft Access 2010 - a jargon free guideMicrosoft Access 2010 - a jargon free guide
Microsoft Access 2010 - a jargon free guidePaul Barnett
 
Lead Management in SugarCRM Series: Viewing Leads
Lead Management in SugarCRM Series: Viewing LeadsLead Management in SugarCRM Series: Viewing Leads
Lead Management in SugarCRM Series: Viewing LeadsAtcore Systems
 
Angel Premium Hair Training Manual
Angel Premium Hair Training ManualAngel Premium Hair Training Manual
Angel Premium Hair Training Manualamitdeyus
 
How To Use CherryPie: Creating Offers
How To Use CherryPie: Creating OffersHow To Use CherryPie: Creating Offers
How To Use CherryPie: Creating OffersPassKit
 
03. data forms in hyperion planning
03. data forms in hyperion planning03. data forms in hyperion planning
03. data forms in hyperion planningepmvirtual.com
 
HARJOT.ppt
HARJOT.pptHARJOT.ppt
HARJOT.pptsatgup78
 

Similar to MS Access Subform Success (20)

MS Access - Create Form.pdf
MS Access - Create Form.pdfMS Access - Create Form.pdf
MS Access - Create Form.pdf
 
CIS 310 ACCESS AssignmentObjective of this assignment is to pr.docx
CIS 310 ACCESS AssignmentObjective of this assignment is to pr.docxCIS 310 ACCESS AssignmentObjective of this assignment is to pr.docx
CIS 310 ACCESS AssignmentObjective of this assignment is to pr.docx
 
Micro Soft Access - Creating Forms
Micro Soft Access - Creating FormsMicro Soft Access - Creating Forms
Micro Soft Access - Creating Forms
 
Lead Management in SugarCRM Series: Adding Leads and Opportunities
Lead Management in SugarCRM Series: Adding Leads and OpportunitiesLead Management in SugarCRM Series: Adding Leads and Opportunities
Lead Management in SugarCRM Series: Adding Leads and Opportunities
 
A. Lab # BSBA BIS245A-7B. Lab 7 of 7 Database Navigation.docx
A. Lab #  BSBA BIS245A-7B. Lab 7 of 7  Database Navigation.docxA. Lab #  BSBA BIS245A-7B. Lab 7 of 7  Database Navigation.docx
A. Lab # BSBA BIS245A-7B. Lab 7 of 7 Database Navigation.docx
 
183201020 sales force-class-5
183201020 sales force-class-5183201020 sales force-class-5
183201020 sales force-class-5
 
Lesson Five Building Table Relationships
Lesson Five   Building Table RelationshipsLesson Five   Building Table Relationships
Lesson Five Building Table Relationships
 
acct accounting Table Lab.pdf
acct accounting Table Lab.pdfacct accounting Table Lab.pdf
acct accounting Table Lab.pdf
 
CIS 3100 - Database Design and ImplementationProducts on Sale Da.docx
CIS 3100 - Database Design and ImplementationProducts on Sale Da.docxCIS 3100 - Database Design and ImplementationProducts on Sale Da.docx
CIS 3100 - Database Design and ImplementationProducts on Sale Da.docx
 
06.ms acess
06.ms acess06.ms acess
06.ms acess
 
Computer Assignment #2 Company Database GuideCustomer Table Da.docx
Computer Assignment #2 Company Database GuideCustomer Table Da.docxComputer Assignment #2 Company Database GuideCustomer Table Da.docx
Computer Assignment #2 Company Database GuideCustomer Table Da.docx
 
Form Design: Best Practices to Improve Conversions
Form Design: Best Practices to Improve ConversionsForm Design: Best Practices to Improve Conversions
Form Design: Best Practices to Improve Conversions
 
Power BI Data Modeling.pdf
Power BI Data Modeling.pdfPower BI Data Modeling.pdf
Power BI Data Modeling.pdf
 
- Database Design and ImplementationProducts on Sale Database fo.docx
- Database Design and ImplementationProducts on Sale Database fo.docx- Database Design and ImplementationProducts on Sale Database fo.docx
- Database Design and ImplementationProducts on Sale Database fo.docx
 
Microsoft Access 2010 - a jargon free guide
Microsoft Access 2010 - a jargon free guideMicrosoft Access 2010 - a jargon free guide
Microsoft Access 2010 - a jargon free guide
 
Lead Management in SugarCRM Series: Viewing Leads
Lead Management in SugarCRM Series: Viewing LeadsLead Management in SugarCRM Series: Viewing Leads
Lead Management in SugarCRM Series: Viewing Leads
 
Angel Premium Hair Training Manual
Angel Premium Hair Training ManualAngel Premium Hair Training Manual
Angel Premium Hair Training Manual
 
How To Use CherryPie: Creating Offers
How To Use CherryPie: Creating OffersHow To Use CherryPie: Creating Offers
How To Use CherryPie: Creating Offers
 
03. data forms in hyperion planning
03. data forms in hyperion planning03. data forms in hyperion planning
03. data forms in hyperion planning
 
HARJOT.ppt
HARJOT.pptHARJOT.ppt
HARJOT.ppt
 

Recently uploaded

Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 

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