Access VBA get values from listbox

Selecting the First Item in the ListBox on Your Microsoft Access Form

Provided by: FMS Development Team

Rather than not selecting a value for list box controls or setting a specific default value, you can set it to the first value in the list. This lets your list manage what's selected and will always be correct regardless if the list of options changes.

You can programmatically select the first item in the list by adding this code to the form's Form_Open event.

Here's an example for a list box named lstBox:

If IsNull[Me.lstBox] Then Me.lstBox = Me.lstBox.ItemData[0] End If

IsNull is used to avoid setting this value if there's an existing value.

For more details, visit

  • Selecting the First Item in a ComboBox or ListBox on a Microsoft Access Form
  • Creating Cascading Combo Boxes and List Boxes on Microsoft Access Forms

Resources for Microsoft Access Forms, Combo Boxes and Tabs

  • Copy and Paste a Command Button on a Form without Losing the Picture NEW!
  • Top Six Tips for Using Combo Boxes on Microsoft Access Forms Updated!
  • Creating Cascading Combo Boxes and List Boxes on Microsoft Access Forms
  • Tips and Techniques for Using and Validating Microsoft Access Combo Boxes
  • Using Combo Boxes to Auto-Fill City and State from USPS Zip Code Database
  • Synchronize Two Related Subforms on a Microsoft Access Form
  • Performance Tip: Use Late Binding for Microsoft Access Subforms on Tab Pages
  • Reference Tab Pages by its PageIndex Rather than Tab Value on Microsoft Access Forms
  • Using the Form Navigation Caption in Microsoft Access
  • Microsoft Access Form Design Tips
  • Microsoft Access Tips to Avoid 17 Common Form Design Mistakes
  • Microsoft Access Developer and Programming Help Center

Video liên quan

Chủ Đề