SlideShare a Scribd company logo
MS Access How To:
Alter the contents of a
list box
Unit 18 Database Design
Extended Diploma in ICT
List boxes
• On a form you often want to have a list box
where the contents change based on the
selection of another list box
• This can be achieved by modifying the
selection process Access uses when making
list boxes and adding a tiny bit of VBA
Example
• You want to select a genre of costumes, then
only show the costumes in that genre for
selection
Data
• When we select the genre “Historical” we
only want “Elizabeth 1” to appear as a choice
Create a form
• We use the link table as the control source
and add the costume ID to it
• The form is saved as ListBoxPopulation
Add list boxes
• Drag out a list box and use the wizard to
make the list box show the genres (see the
How To on list boxes and sub forms for
details). Name it lstGenre in the property
sheet
Genre list box
• This will now show the genres, but should not
update the CostumeID
Add the costume list box
• Add another list box for costumes and make
sure it will store the value in the CostumeID
field. Call it lstCostume
Two independent list boxes
• We now have 2 list boxes that are not
connected
• Selecting a costume should update the
costumeID
Linking the list boxes
• We need to edit the queries that Access uses
to populate the list boxes
• Select the costume list box
• The query is in the Row Source. Click on the
three dots
View the query in SQL
• The query opens in design view
• Click on View and select SQL
The SQL statement
• The SQL view shows the SQL statement
Takes the
data from
tblCostume
Gets the
CostumeID
Gets the
CostumeType
Command
to extract
data from
a table
Only selecting one record
• We need to make sure we only list one
record if there could be duplicates
• Modify the SQL for lstGenre list box to the
following:
• SELECT DISTINCTROW tblGenre.GenreID, tblGenre.Genre
FROM tblGenre;
• And for the lstCostume list box to:
• SELECT DISTINCTROW tblCostume.CostumeID,
tblCostume.CostumeType FROM tblCostume;
Modification to only get data
that matches the genre
• We can use a WHERE statement to get the
data where the GenreID in the costume table
matches the GenreID value in the list box
SELECT tblCostume.CostumeID, tblCostume.CostumeType
FROM tblCostume
WHERE (((tblCostume.GenreID)=[forms]![ListBoxPopulation]!
[lstGenre]));
GenreID in
the
costume
table
matches the form
with the
contents of
this list box
Refreshing the list box
• The list box for Costume should now only show
the costumes associated with the chosen genre,
but it doesn’t.
• This is because lstCostume needs refreshing
after a change has been made to lstGenre
• This done by adding VBA to the After Update
event of lstGenre
Requery
• We add a VBA statement to rerun the query
that populates the costume list box.
Final result
• We now have the costume list box contents
changing depending on the selected genre

More Related Content

What's hot

05.formatting cells
05.formatting cells05.formatting cells
05.formatting cells
Steven Alphonce
 
Create an index and update an index in word
Create an index and update an index in wordCreate an index and update an index in word
Create an index and update an index in wordRaghu nath
 
Libre Office Writer Lesson 2
Libre Office Writer Lesson 2Libre Office Writer Lesson 2
Libre Office Writer Lesson 2
Smart Chicago Collaborative
 
Conditional formatting in excel v2
Conditional formatting in excel v2Conditional formatting in excel v2
Conditional formatting in excel v2
m182348
 
Refworks manual entry - Classic
Refworks manual entry - ClassicRefworks manual entry - Classic
Refworks manual entry - Classic
UCT
 
Refworks Manual Entry
Refworks Manual EntryRefworks Manual Entry
Refworks Manual Entry
UCT
 
5.1 Creating a Form Using AutoForm
5.1 Creating a Form Using AutoForm5.1 Creating a Form Using AutoForm
5.1 Creating a Form Using AutoForm
Pyi Soe
 
Print11
Print11Print11
Print11
Hassan Samoon
 
Xml For Dummies Chapter 16 Xml And Forms it-slideshares.blogspot.com
Xml For Dummies   Chapter 16 Xml And Forms it-slideshares.blogspot.comXml For Dummies   Chapter 16 Xml And Forms it-slideshares.blogspot.com
Xml For Dummies Chapter 16 Xml And Forms it-slideshares.blogspot.com
phanleson
 
Filter Data in Excel Services SharePoint 2010 - EPC Group
Filter Data in Excel Services SharePoint 2010 - EPC GroupFilter Data in Excel Services SharePoint 2010 - EPC Group
Filter Data in Excel Services SharePoint 2010 - EPC Group
EPC Group
 
Formatting text (Microsoft Excel)
Formatting text (Microsoft Excel)Formatting text (Microsoft Excel)
Formatting text (Microsoft Excel)
Mirea Mizushima
 
Lesson 11 Formatting Tables
Lesson 11   Formatting TablesLesson 11   Formatting Tables
Lesson 11 Formatting Tablesguevarra_2000
 
Advanced DB - Chapter 1 Slides
Advanced DB - Chapter 1 SlidesAdvanced DB - Chapter 1 Slides
Advanced DB - Chapter 1 Slidesguest347745
 
Lesson4 Formatting Text
Lesson4 Formatting TextLesson4 Formatting Text
Lesson4 Formatting Textguevarra_2000
 
Editing worksheet data (Microsoft Excel)
Editing worksheet data (Microsoft Excel)Editing worksheet data (Microsoft Excel)
Editing worksheet data (Microsoft Excel)
Mirea Mizushima
 
SA05 - Customizing the User Interface
SA05 - Customizing the User Interface SA05 - Customizing the User Interface
SA05 - Customizing the User Interface
Maintenance Connection
 
Lesson 9 working with text boxes
Lesson 9   working with text boxesLesson 9   working with text boxes
Lesson 9 working with text boxesguevarra_2000
 
Css selectors
Css selectorsCss selectors
Css selectors
Parth Trivedi
 
Chapter 10.1.5
Chapter 10.1.5Chapter 10.1.5
Chapter 10.1.5patcha535
 

What's hot (20)

05.formatting cells
05.formatting cells05.formatting cells
05.formatting cells
 
Create an index and update an index in word
Create an index and update an index in wordCreate an index and update an index in word
Create an index and update an index in word
 
Libre Office Writer Lesson 2
Libre Office Writer Lesson 2Libre Office Writer Lesson 2
Libre Office Writer Lesson 2
 
Conditional formatting in excel v2
Conditional formatting in excel v2Conditional formatting in excel v2
Conditional formatting in excel v2
 
Refworks manual entry - Classic
Refworks manual entry - ClassicRefworks manual entry - Classic
Refworks manual entry - Classic
 
Refworks Manual Entry
Refworks Manual EntryRefworks Manual Entry
Refworks Manual Entry
 
5.1 Creating a Form Using AutoForm
5.1 Creating a Form Using AutoForm5.1 Creating a Form Using AutoForm
5.1 Creating a Form Using AutoForm
 
Libre Office Writer Lesson 1
Libre Office Writer Lesson 1Libre Office Writer Lesson 1
Libre Office Writer Lesson 1
 
Print11
Print11Print11
Print11
 
Xml For Dummies Chapter 16 Xml And Forms it-slideshares.blogspot.com
Xml For Dummies   Chapter 16 Xml And Forms it-slideshares.blogspot.comXml For Dummies   Chapter 16 Xml And Forms it-slideshares.blogspot.com
Xml For Dummies Chapter 16 Xml And Forms it-slideshares.blogspot.com
 
Filter Data in Excel Services SharePoint 2010 - EPC Group
Filter Data in Excel Services SharePoint 2010 - EPC GroupFilter Data in Excel Services SharePoint 2010 - EPC Group
Filter Data in Excel Services SharePoint 2010 - EPC Group
 
Formatting text (Microsoft Excel)
Formatting text (Microsoft Excel)Formatting text (Microsoft Excel)
Formatting text (Microsoft Excel)
 
Lesson 11 Formatting Tables
Lesson 11   Formatting TablesLesson 11   Formatting Tables
Lesson 11 Formatting Tables
 
Advanced DB - Chapter 1 Slides
Advanced DB - Chapter 1 SlidesAdvanced DB - Chapter 1 Slides
Advanced DB - Chapter 1 Slides
 
Lesson4 Formatting Text
Lesson4 Formatting TextLesson4 Formatting Text
Lesson4 Formatting Text
 
Editing worksheet data (Microsoft Excel)
Editing worksheet data (Microsoft Excel)Editing worksheet data (Microsoft Excel)
Editing worksheet data (Microsoft Excel)
 
SA05 - Customizing the User Interface
SA05 - Customizing the User Interface SA05 - Customizing the User Interface
SA05 - Customizing the User Interface
 
Lesson 9 working with text boxes
Lesson 9   working with text boxesLesson 9   working with text boxes
Lesson 9 working with text boxes
 
Css selectors
Css selectorsCss selectors
Css selectors
 
Chapter 10.1.5
Chapter 10.1.5Chapter 10.1.5
Chapter 10.1.5
 

Viewers also liked

04 access howtobuttons
04 access howtobuttons04 access howtobuttons
04 access howtobuttons
Rebecca Jones
 
08 benefits of e-commerce
08 benefits of e-commerce08 benefits of e-commerce
08 benefits of e-commerceRebecca Jones
 
Importing MS Word Documents in AuthorIT
Importing MS Word Documents in AuthorITImporting MS Word Documents in AuthorIT
Importing MS Word Documents in AuthorIT
Raghuram Pandurangan
 
Ms word tutorial tec 537.pptx
Ms word tutorial tec 537.pptxMs word tutorial tec 537.pptx
Ms word tutorial tec 537.pptxDrE-TEC
 
IMPORT AND EXPORT UTILITIES IN MS-ACCESS
IMPORT AND EXPORT UTILITIES IN MS-ACCESSIMPORT AND EXPORT UTILITIES IN MS-ACCESS
IMPORT AND EXPORT UTILITIES IN MS-ACCESS
23HARSHU
 
Ms access
Ms accessMs access
Ms access
Pooja Vaidhya
 
Step by step wudu guide
Step by step wudu guideStep by step wudu guide
Step by step wudu guideaatiqah nyla
 
Ms access 2010
Ms access 2010Ms access 2010
Ms access 2010
Alsufaacademy
 
Ecommerce Security
Ecommerce SecurityEcommerce Security
Ecommerce Security
Rebecca Jones
 
MS Access and Database Fundamentals
MS Access and Database FundamentalsMS Access and Database Fundamentals
MS Access and Database Fundamentals
Ananda Gupta
 
Basic introduction to ms access
Basic introduction to ms accessBasic introduction to ms access
Basic introduction to ms access
jigeno
 
Access presentation
Access presentationAccess presentation
Access presentationDUSPviz
 
Introduction to microsoft access
Introduction to microsoft accessIntroduction to microsoft access
Introduction to microsoft accessHardik Patel
 
Ms access
Ms accessMs access
Training MS Access 2007
Training MS Access 2007Training MS Access 2007
Training MS Access 2007
crespoje
 
Master database management for cxc
Master database management for cxcMaster database management for cxc
Master database management for cxc
lenghorne
 

Viewers also liked (20)

8
88
8
 
7
77
7
 
04 access howtobuttons
04 access howtobuttons04 access howtobuttons
04 access howtobuttons
 
9
99
9
 
08 benefits of e-commerce
08 benefits of e-commerce08 benefits of e-commerce
08 benefits of e-commerce
 
Importing MS Word Documents in AuthorIT
Importing MS Word Documents in AuthorITImporting MS Word Documents in AuthorIT
Importing MS Word Documents in AuthorIT
 
Ms word tutorial tec 537.pptx
Ms word tutorial tec 537.pptxMs word tutorial tec 537.pptx
Ms word tutorial tec 537.pptx
 
IMPORT AND EXPORT UTILITIES IN MS-ACCESS
IMPORT AND EXPORT UTILITIES IN MS-ACCESSIMPORT AND EXPORT UTILITIES IN MS-ACCESS
IMPORT AND EXPORT UTILITIES IN MS-ACCESS
 
Ms access
Ms accessMs access
Ms access
 
Step by step wudu guide
Step by step wudu guideStep by step wudu guide
Step by step wudu guide
 
Ms access 2010
Ms access 2010Ms access 2010
Ms access 2010
 
Ecommerce Security
Ecommerce SecurityEcommerce Security
Ecommerce Security
 
MS Access and Database Fundamentals
MS Access and Database FundamentalsMS Access and Database Fundamentals
MS Access and Database Fundamentals
 
Basic introduction to ms access
Basic introduction to ms accessBasic introduction to ms access
Basic introduction to ms access
 
Access presentation
Access presentationAccess presentation
Access presentation
 
Introduction to microsoft access
Introduction to microsoft accessIntroduction to microsoft access
Introduction to microsoft access
 
Ms access
Ms accessMs access
Ms access
 
Training MS Access 2007
Training MS Access 2007Training MS Access 2007
Training MS Access 2007
 
Ms powerpoint
Ms powerpointMs powerpoint
Ms powerpoint
 
Master database management for cxc
Master database management for cxcMaster database management for cxc
Master database management for cxc
 

Similar to 6

Access 03
Access 03Access 03
Access 03
Alexander Babich
 
Sql Commands
Sql CommandsSql Commands
Sql CommandsSachin MK
 
Mangala Deshpande MySQL0710.ppt
Mangala Deshpande MySQL0710.pptMangala Deshpande MySQL0710.ppt
Mangala Deshpande MySQL0710.ppt
Mihir Shah
 
DB2 Sql Query
DB2 Sql QueryDB2 Sql Query
DB2 Sql Query
Hari Christian
 
MS Excel Learning for PPC Google AdWords Training Course
MS Excel Learning for PPC Google AdWords Training CourseMS Excel Learning for PPC Google AdWords Training Course
MS Excel Learning for PPC Google AdWords Training Course
Ranjan Jena
 
SQL DDL
SQL DDLSQL DDL
SQL DDL
Vikas Gupta
 
SQL
SQLSQL
Sql
SqlSql
Basic controls in asp
Basic controls in aspBasic controls in asp
Basic controls in asp
Sireesh K
 
IOS Swift Language 4th tutorial
IOS Swift Language 4th tutorialIOS Swift Language 4th tutorial
IOS Swift Language 4th tutorial
Hassan A-j
 
Crosstab query techniques
Crosstab query techniquesCrosstab query techniques
Crosstab query techniquesaabaap
 
working with database using mysql
working with database using mysql working with database using mysql
working with database using mysql
Subhasis Nayak
 
Php, mysq lpart5(mysql)
Php, mysq lpart5(mysql)Php, mysq lpart5(mysql)
Php, mysq lpart5(mysql)
Subhasis Nayak
 
Optimizing MySQL queries
Optimizing MySQL queriesOptimizing MySQL queries
Optimizing MySQL queries
GMO-Z.com Vietnam Lab Center
 
Collections (1)
Collections (1)Collections (1)
Collections (1)
abdullah619
 
SQL Commands Part 1.pptx
SQL Commands Part 1.pptxSQL Commands Part 1.pptx
SQL Commands Part 1.pptx
RUBAB79
 
Pandas csv
Pandas csvPandas csv
Pandas csv
Devashish Kumar
 

Similar to 6 (20)

Access 03
Access 03Access 03
Access 03
 
Sql Commands
Sql CommandsSql Commands
Sql Commands
 
Mangala Deshpande MySQL0710.ppt
Mangala Deshpande MySQL0710.pptMangala Deshpande MySQL0710.ppt
Mangala Deshpande MySQL0710.ppt
 
Mysql Optimization
Mysql OptimizationMysql Optimization
Mysql Optimization
 
DB2 Sql Query
DB2 Sql QueryDB2 Sql Query
DB2 Sql Query
 
MS Excel Learning for PPC Google AdWords Training Course
MS Excel Learning for PPC Google AdWords Training CourseMS Excel Learning for PPC Google AdWords Training Course
MS Excel Learning for PPC Google AdWords Training Course
 
SQL DDL
SQL DDLSQL DDL
SQL DDL
 
SQL
SQLSQL
SQL
 
Sql
SqlSql
Sql
 
Basic controls in asp
Basic controls in aspBasic controls in asp
Basic controls in asp
 
IOS Swift Language 4th tutorial
IOS Swift Language 4th tutorialIOS Swift Language 4th tutorial
IOS Swift Language 4th tutorial
 
Crosstab query techniques
Crosstab query techniquesCrosstab query techniques
Crosstab query techniques
 
working with database using mysql
working with database using mysql working with database using mysql
working with database using mysql
 
Php, mysq lpart5(mysql)
Php, mysq lpart5(mysql)Php, mysq lpart5(mysql)
Php, mysq lpart5(mysql)
 
Optimizing MySQL queries
Optimizing MySQL queriesOptimizing MySQL queries
Optimizing MySQL queries
 
Collections (1)
Collections (1)Collections (1)
Collections (1)
 
SQL_Part1
SQL_Part1SQL_Part1
SQL_Part1
 
Sql basics
Sql  basicsSql  basics
Sql basics
 
SQL Commands Part 1.pptx
SQL Commands Part 1.pptxSQL Commands Part 1.pptx
SQL Commands Part 1.pptx
 
Pandas csv
Pandas csvPandas csv
Pandas csv
 

Recently uploaded

Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
Celine George
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
Celine George
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
Nguyen Thanh Tu Collection
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
GeoBlogs
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 

Recently uploaded (20)

Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 

6

  • 1. MS Access How To: Alter the contents of a list box Unit 18 Database Design Extended Diploma in ICT
  • 2. List boxes • On a form you often want to have a list box where the contents change based on the selection of another list box • This can be achieved by modifying the selection process Access uses when making list boxes and adding a tiny bit of VBA
  • 3. Example • You want to select a genre of costumes, then only show the costumes in that genre for selection
  • 4. Data • When we select the genre “Historical” we only want “Elizabeth 1” to appear as a choice
  • 5. Create a form • We use the link table as the control source and add the costume ID to it • The form is saved as ListBoxPopulation
  • 6. Add list boxes • Drag out a list box and use the wizard to make the list box show the genres (see the How To on list boxes and sub forms for details). Name it lstGenre in the property sheet
  • 7. Genre list box • This will now show the genres, but should not update the CostumeID
  • 8. Add the costume list box • Add another list box for costumes and make sure it will store the value in the CostumeID field. Call it lstCostume
  • 9. Two independent list boxes • We now have 2 list boxes that are not connected • Selecting a costume should update the costumeID
  • 10. Linking the list boxes • We need to edit the queries that Access uses to populate the list boxes • Select the costume list box • The query is in the Row Source. Click on the three dots
  • 11. View the query in SQL • The query opens in design view • Click on View and select SQL
  • 12. The SQL statement • The SQL view shows the SQL statement Takes the data from tblCostume Gets the CostumeID Gets the CostumeType Command to extract data from a table
  • 13. Only selecting one record • We need to make sure we only list one record if there could be duplicates • Modify the SQL for lstGenre list box to the following: • SELECT DISTINCTROW tblGenre.GenreID, tblGenre.Genre FROM tblGenre; • And for the lstCostume list box to: • SELECT DISTINCTROW tblCostume.CostumeID, tblCostume.CostumeType FROM tblCostume;
  • 14. Modification to only get data that matches the genre • We can use a WHERE statement to get the data where the GenreID in the costume table matches the GenreID value in the list box SELECT tblCostume.CostumeID, tblCostume.CostumeType FROM tblCostume WHERE (((tblCostume.GenreID)=[forms]![ListBoxPopulation]! [lstGenre])); GenreID in the costume table matches the form with the contents of this list box
  • 15. Refreshing the list box • The list box for Costume should now only show the costumes associated with the chosen genre, but it doesn’t. • This is because lstCostume needs refreshing after a change has been made to lstGenre • This done by adding VBA to the After Update event of lstGenre
  • 16. Requery • We add a VBA statement to rerun the query that populates the costume list box.
  • 17. Final result • We now have the costume list box contents changing depending on the selected genre