Drop-down list

Description

A drop-down list field “expands” to show a list of items, then collapses to show only the selected item.

Events

The BeforeUserChanged and AfterUserChanged events run each time the user selects an item in the drop-down list, or presses the up arrow or down arrow key to move to a different list item. All other VBA field events function normally for a focusable drop-down list field.

VBA usage

VBA uses a numeric value (1 to n) when referencing items in a drop-down list. In most cases, the value corresponds to the position of the item in the list. You cannot reference the name of the item in the list, nor can you rearrange, remove or add items to a drop-down list using VBA.

Comments

In certain instances, the position of an item in a drop-down list doesn’t necessarily correspond to its numeric value. This is especially true if the list is sorted in alphanumeric order. To determine the correct value, select the item in the list, then view the field’s Value property using the Visual Basic Editor’s Property sheet.

Example

In the following example, an event procedure sets the default position of the sort list and the Document Type drop-down list fields in the Receivables Transaction Entry window:

Private Sub Window_BeforeOpen(OpenVisible As Boolean)
	SortBy = 4		'Sets the sort list to "By Batch ID"
	DocumentType = 7	'Sets the Document Type to "Returns"
End Sub


Documentation Feedback