다음을 통해 공유


ListBox Object (Access)

This object corresponds to a list box control. The list box control displays a list of values or alternatives.

Remarks

In many cases, it's quicker and easier to select a value from a list than to remember a value to type. A list of choices also helps ensure that the value that's entered in a field is correct.

Control:

Tool:

Ff195480.t-lstbox_ZA06053984(ko-kr,office.14).gif

Ff195480.listbox_ZA06044481(ko-kr,office.14).gif

참고

The list in a list box consists of rows of data. Rows can have one or more columns, which can appear with or without headings.

Ff195480.cfrmlst2_ZA06047456(ko-kr,office.14).gif

If a multiple-column list box is bound, Microsoft Access stores the values from one of the columns.

You can use an unbound list box to store a value that you can use with another control. For example, you could use an unbound list box to limit the values in another list box or in a custom dialog box. You could also use an unbound list box to find a record based on the value you select in the list box.

If you don't have room on your form to display a list box, or if you want to be able to type new values as well as select values from a list, use a combo box instead of a list box.

Links provided by:커뮤니티 구성원 아이콘 The UtterAccess community | About the Contributors

Example

This example demonstrates how to filter the contents of a list box while you are typing in a text box.

In this example, a list box named ColorID displays a list of colors stored in the Colors table. As you type in the FilterBy text box, the items in ColorID are filtered dynamically

To do this, use the Change event of the text box to build a SQL statement that will serve as the new RowSource of the list box.

Sample code provided by:커뮤니티 구성원 아이콘 The UtterAccess community | About the Contributors

Private Sub FilterBy_Change()

    Dim sql As String
    
    'This will match any entry in the list that begins with what the user 
    ‘has typed in the FilterBy control
    sql = "SELECT ColorID, ColorName FROM Colors WHERE ColorName Like '" & Me.FilterBy.Text & "*' ORDER BY ColorName"
    
    'If you want to match any part of the string then add wildcard (*) before
    ‘the FilterBy.Text, too:
    'sql = "SELECT ColorID, ColorName FROM Colors WHERE ColorName Like '*" & Me.FilterBy.Text & "*' ORDER BY ColorName"
    
    Me.ColorID.RowSource = sql
    
End Sub

About the Contributors

UtterAccess(영문일 수 있음)는 Microsoft Access 위키 및 도움말 포럼입니다. 가입하려면 여기를 클릭하십시오(영문일 수 있음).

참고 항목

개념

ListBox Object Members

Access Object Model Reference