Jump: Search for: 

Free Resources from FMS

 

Thank you! Thank you! I just finished reading this document, which was part of a link in the recent Buzz newsletter. I have printed it for others to read, especially those skeptical on the powers of Access and its capabilities.

Darren D.

 

 

 

 

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.br />

Return to the tips page

Feedback

Contact Us  l   Web questions: Webmaster   l   Copyright © 2010 FMS, Inc., Vienna, Virginia
Celebrating 24 Years of Software Excellence