How to Add Items from Textbox to Listbox

How to Add Items to Listbox

A Listbox is also well known like Combo box in the MS Access form. How to create a Listbox is similar to creating a Combobox. You can see more details on Working with Combo box How To on my website.  In this How To, I will show how to add an item from a textbox into a list box.

 Step 1. Add List Box to Form

–          Under the Design Menu, click a List Box icon then place it on top of form

–          It will open the List Box Wizard below

–          Click Cancel button to cancel List Box wizard

–          Rename list label as Customer List:

–          Click Data tab of the Property Sheet

–          Select Value List for the Row Source Type

–          Name a list box as lstCustomer

Step 2. Add Textbox to Form

–          Click on Textbox icon and drag it to form

–          Select Textbox and name it as txtName

–          Rename text label as Name:

Step 3. Add Command Button to Form

–          Click on Command button icon

–          Place it next to the textbox Name

–          Select Command button

–          Rename a button label as Add to List:


–          Open the Property Sheet of Add to List button

–          Click Event tab

–          Select [Event Procedure] of On Click event

–          Click three dots() at the end of [Event Procedure]

–          Enter VBA code below:

Private Sub Command2_Click()
   Me.lstCustomer.AddItem (Me.txtName)
   Me.txtName = Null
End Sub


Step 4. Adding Text to Listbox

You will see the form view like picture below after completing adding the listbox, textbox, and button.

We just type the name of customer in the Name textbox then click on Add to List button. The name will be added into the listbox below.

Related posts