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

SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 

Recently uploaded (20)

SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 

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