Country ListTop Six Tips for Using Combo Boxes on Microsoft Access Forms

Provided by Molly Pell, Senior Systems Analyst and Luke Chung, FMS President

Microsoft Access combo boxes let you display data for users to select values from predefined lists. Using them effectively simplifies data entry and accuracy.

Most commonly, the list of values is from a table or query, and can be bound to one field (like an ID field) while displaying a field the user sees and understands. Combo boxes in Access also support the display of multiple columns so you can show more data to make it easier to select the right item.

Brush up on the Combo Box Basics from Microsoft, and check out our Top Six Tips for using Combo Boxes on Microsoft Access forms. Each has articles describing them in more detail.

Combo Box Tips


To use combo boxes effectively, learn about the following properties:

  • LimitToList: Set this property to Yes to prevent values that are not in your list.
  • AutoExpand: Set this property to Yes to automatically select a matching value in the list as you type.
  • ListRows: Set this value to a high value so that the drop down shows as many list items as space allows.

For more information, visit Setting Microsoft Access Combo Box Display Properties

In forms, the BeforeUpdate event is used to validate the entries in the current record. For Combo Boxes, people often check if the value exists by looking for Null. This works in most cases, but not all.

If the combo box is on a bound field, there may be an existing value that is not valid. For example, the value may have been in the list when it was originally selected, but the current list of allowed values has changed.

If you simply check for IsNull, Access says it is not null. This is accurate, but what you really want to know is if a valid value was selected.

Instead, you should use the ListIndex property:

If Me.cboName.ListIndex = -1 Then
  MsgBox "A value is required for ...."
  Me.cboName.SetFocus
  Cancel = True
End If

For more information, visit Properly Validating Microsoft Access Combo Boxes with the ListIndex Property

Use the following syntax to automatically select the first item in a Combo Box when the form loads, or when the value of another control on the form changes:

Me.ControlName = Me.ControlName.ItemData(0)

This lets you default to the first value and rely on the value in the current list rather than hardcoding a specific value.

For more information, visit Selecting the First Item of a Microsoft Access Combo Box with the ItemData Property

On a form with multiple Combo Boxes, you may want to make the selection in one Combo Box limit the choices in another Combo Box. To do this, add code to the AfterUpdate event of the first control that updates the RowSource property of the second control:

Microsoft Access Cascading Combo Boxes

Private Sub cboKingdomID_AfterUpdate()
  ' Set the second combo box to be limited by the first
  Me.cboPhylumID.RowSource = "SELECT PhylumID, PhylumName " & _
    "FROM tblPhylum " & _
    "WHERE KingdomID = " & Nz(Me.cboKingdomID) & _  
    "ORDER BY PhylumName"
End Sub

For more information, visit Creating Cascading Combo Boxes and List Boxes on Microsoft Access Forms

The list in the Combo Box dropdown is created when the form/table is loaded or if its row source is refreshed programmatically.

If the list is based on a table that is updated with new values after the combo box is loaded, the new values do not automatically appear in the list.

You can close and reopen to form/table to update the list, or you simply go to the combo box and press the F9 key. F9 refreshes the combo box list with the current data.

For data entry of addresses, we like to speed data entry and improve accuracy by forcing users to select countries from a combo box list, along with state if it's a country with a state list. Additionally, we use a zip code lookup table to fill in city and state values. This improve accuracy by eliminating typos on city names and flagging wrong zip codes if the city doesn't match.

Some zip codes have multiple acceptable cities. With a zip code lookup table from the US Postal Service (provided by our Total Zip Code Database subscription), we can easily provide a lookup for city and state, plus add a Combo Box for selecting valid city names:

Microsoft Access Zip Code Lookup for City State Autofill and City Combo Box Selection
Example of Country and State Combo Boxes with Zip Code Lookup of City/State Names and Multiple City Combo Box

For more information, visit Zip Code Entry and Auto-Fill City and State Names on Microsoft Access Forms


Resources for Microsoft Access Forms, Combo Boxes and Tabs

Table Design

Query Design

Form Design

Form Tips and Mistakes

Copy Command Button and Keep Picture

Module VBA to Forms and Controls

Form Navigation Caption

Resync Record in a Subform

Synchronize Two Subforms

Multiple OpenArgs Values

Late Bind Tab Subforms

Subform Reference to Control Rather than Field

Tab Page Reference

Shortcut Keys


Combo Box Top 6 Tips

Properties and Validation

Select First Item

Cascading Combo Boxes

Zip, City, State AutoFill

Report Design

Suppress Page Headers and Footers on the First Page of Your Report

Add the NoData Event

Annual Monthly Crosstab Columns

Design Environment

Add Buttons to the Quick Access Toolbar

Collapse the Office Ribbon for more space

VBA Programming

Basics: Forms and Controls

Run VBA Code from a Macro

Use Nz() to Handle Nulls

Avoid Exits in the Body of a Procedure

Shortcut Debugging Keys

Set Module Options

Math Rounding Issues

Rename a File or Folder

Avoid DoEvents in Loops

Age Calculations

Weekday Math

Send Emails with DoCmd.SendObject

Source Code Library

Microsoft Access Modules Library

Microsoft Access Modules

VBA Error Handling

Error Handling and Debugging Techniques

Error Number and Description Reference

Basic Error Handling

Pinpointing the Error Line

Performance Tips

Linked Database

Subdatasheet Name

Visual SourceSafe

Deployment

Runtime Downloads

Simulate Runtime

Prevent Close Box

Disable Design Changes

Broken References

Remote Desktop Connection Setup

Terminal Services and RemoteApp Deployment

Reboot Remote Desktop

Missing Package & Deployment Wizard

Avoid Program Files Folder

Unavailable Mapped Drives

Microsoft Access Front-End Deployment

System Admin

Disaster Recovery Plan

Compact Database

Compact on Close

Database Corruption

Remove 'Save to SharePoint Site' Prompt from an Access Database

Class Not Registered Run-time Error -2147221164

Inconsistent Compile Error

Decompile Database

Bad DLL Calling Convention

Error 3045: Could Not Use

Converting ACCDB to MDB

SQL Server Upsizing

Microsoft Access to SQL Server Upsizing Center

Microsoft Access to SQL Server Upsizing Center

When and How to Upsize Access to SQL Server

SQL Server Express Versions and Downloads

Cloud and Azure

Cloud Implications

MS Access and SQL Azure

Deploying MS Access Linked to SQL Azure

SQL Server Azure Usage and DTU Limits

Visual Studio LightSwitch

LightSwitch Introduction

Comparison Matrix

Additional Resources

Connect with Us

 

Free Product Catalog from FMS