SlideShare a Scribd company logo
1 of 17
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 cellsSteven 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
 
Conditional formatting in excel v2
Conditional formatting in excel v2Conditional formatting in excel v2
Conditional formatting in excel v2m182348
 
Refworks manual entry - Classic
Refworks manual entry - ClassicRefworks manual entry - Classic
Refworks manual entry - ClassicUCT
 
Refworks Manual Entry
Refworks Manual EntryRefworks Manual Entry
Refworks Manual EntryUCT
 
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 AutoFormPyi Soe
 
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.comphanleson
 
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 GroupEPC 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
 
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 howtobuttonsRebecca 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 AuthorITRaghuram 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-ACCESS23HARSHU
 
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 2010Alsufaacademy
 
Ecommerce Security
Ecommerce SecurityEcommerce Security
Ecommerce SecurityRebecca Jones
 
MS Access and Database Fundamentals
MS Access and Database FundamentalsMS Access and Database Fundamentals
MS Access and Database FundamentalsAnanda Gupta
 
Basic introduction to ms access
Basic introduction to ms accessBasic introduction to ms access
Basic introduction to ms accessjigeno
 
Access presentation
Access presentationAccess presentation
Access presentationDUSPviz
 
Introduction to microsoft access
Introduction to microsoft accessIntroduction to microsoft access
Introduction to microsoft accessHardik Patel
 
Training MS Access 2007
Training MS Access 2007Training MS Access 2007
Training MS Access 2007crespoje
 
Ms powerpoint
Ms powerpointMs powerpoint
Ms powerpointLALIT MAHATO
 
Master database management for cxc
Master database management for cxcMaster database management for cxc
Master database management for cxclenghorne
 

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 MS Access Alter List Box Contents Based on Selection

Sql Commands
Sql CommandsSql Commands
Sql CommandsSachin MK
 
Mangala Deshpande MySQL0710.ppt
Mangala Deshpande MySQL0710.pptMangala Deshpande MySQL0710.ppt
Mangala Deshpande MySQL0710.pptMihir Shah
 
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 CourseRanjan Jena
 
Basic controls in asp
Basic controls in aspBasic controls in asp
Basic controls in aspSireesh K
 
IOS Swift Language 4th tutorial
IOS Swift Language 4th tutorialIOS Swift Language 4th tutorial
IOS Swift Language 4th tutorialHassan A-j
 
Crosstab query techniques
Crosstab query techniquesCrosstab query techniques
Crosstab query techniquesaabaap
 
Php, mysq lpart5(mysql)
Php, mysq lpart5(mysql)Php, mysq lpart5(mysql)
Php, mysq lpart5(mysql)Subhasis Nayak
 
working with database using mysql
working with database using mysql working with database using mysql
working with database using mysql Subhasis Nayak
 
Collections (1)
Collections (1)Collections (1)
Collections (1)abdullah619
 
SQL_Part1
SQL_Part1SQL_Part1
SQL_Part1Rick Perry
 
Sql basics
Sql  basicsSql  basics
Sql basicsGenesis Omo
 
SQL Commands Part 1.pptx
SQL Commands Part 1.pptxSQL Commands Part 1.pptx
SQL Commands Part 1.pptxRUBAB79
 

Similar to MS Access Alter List Box Contents Based on Selection (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
 
Php, mysq lpart5(mysql)
Php, mysq lpart5(mysql)Php, mysq lpart5(mysql)
Php, mysq lpart5(mysql)
 
working with database using mysql
working with database using mysql working with database using mysql
working with database using 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

internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonJericReyAuditor
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 

Recently uploaded (20)

internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lesson
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 

MS Access Alter List Box Contents Based on Selection

  • 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