Jump: Search:

Microsoft Access Developer Center

Table Design

Query Design

Form Design

Form Tips and Mistakes

Form Navigation Caption

First Item in Your ListBox

Validating Combo Boxes

Using a RecordsetClone

Synchronize Two Subforms

Late Bind Tab Subforms

Subform Reference to Control Rather than Field

Tab Page Reference

Report Design

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

Add the NoData Event

Annual Monthly Crosstab Columns

Design Environment

Adding Buttons to the Quick Access Toolbar

Collapsing the Office Ribbon for more space

VBA Programming

Using Nz() to Handle Nulls

Avoiding Exits in the Body of a Procedure

Debugging Keys

Setting Module Options

Math Rounding Issues

Source Code Library

Microsoft Access Module VBA Library

Royalty Free VBA 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

Subsheet Name

Visual Source Safe

Deployment

Prevent Close Box

Disable Design Changes

Broken References

Simulating Runtime

Missing Package & Deployment Wizard

System Admin

Disaster Recovery Plan

Compact Database

Compact on Close

Database Corruption

Decompile Database

Bad DLL Calling Convention

Converting ACCDB to MDB

Cloud and Azure

Cloud Implications

MS Access and SQL Azure

Deploying MS Access Linked to SQL Azure

Additional Resources

Microsoft Access Help

MS Access Developer Programming

More Microsoft Access Tips

Technical Papers

Microsoft Access Tools

Connect with Us

Email NewsletterEmail Newsletter

FMS Development Team BlogDeveloper Team Blog

Facebook PageFacebook

Twitter with FMSTwitter

 

 

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.

Feedback

Contact Us  l   Web questions: Webmaster   l   Copyright © FMS, Inc., Vienna, Virginia
Celebrating our 26th Year of Software Excellence