Info

In the RowSource property of the ListBox, enter the range from which the control should draw its data. Use a dynamic named range to keep the list updated if employees are added:

Private Sub btn_EmpOK_Click() Dim EmpFound As Range With Range("Empl_ist")

Set EmpFound = .Find(lb_EmpName.Value) If EmpFound Is Nothing Then

MsgBox ("Employee not found!") lb_EmpName.Value = "" Exit Sub

Else

With Range(EmpFound.Address)

tb_EmpPosition = .Offset(0, 1) tb_HireDate = .Offset(0, 2) End With End If End With End Sub

Using the Multi-Select Property of a ListBox

ListBoxes have a multi-select property, which allows the user to select multiple items from the choices in the ListBox, as shown in Figure 9.9:

■ fmMultiSelectSingle—The default setting allows only a single item selection at a time.

■ fmMultiSelectMulti—Allows an item to be deselected by clicking on it again; multiple items can also be selected.

■ fmMultiSelectExtended —Allows the Ctrl and Shift keys to be used to select multiple items.

Figure 9.9

Multiselect can allow the user to select multiple items from a ListBox.

Figure 9.9

Multiselect can allow the user to select multiple items from a ListBox.

0 0

Post a comment