• September 22, 2021


Bring Technology Ideas with you

 How to add item from Textbox control to List box in Microsoft Access using VBA programming

We can say VBA programming is the most popular one for everyone to learn or use for small or medium business as DBMS. To work with VBA, you need to use Microsoft Program such as Microsoft Word, Microsoft Excel, Microsoft PowerPoint, Microsoft Access and so on. Visit our previous tutorial for how to write VBA programming in Microsoft Access.

What is a listbox control?

Listbox control is one of the controls which are popular used for storing value or list of value from the other controls or even from Tables from the database. To get this control on Form Object by creating a new form then in Design Tab, please find the control which is named as Listbox

    Listbox Control

    Select on this Listbox control then drag into your form. Due to this tutorial will use VBA so, please select Cancel in your Wizard

      Listbox Wizard

      After that Design the Form just like below example

        Listbox Control To Get Data From Textbox

        Through out this tutorial, you can drag the other control calls Textbox and Button in order to apply VBA programming within Button.

          Design Wizard in Form

          For getting through VBA programming to insert Data from Textbox into Listbox, it needs to rename some controls which can be changed in the Property on the Right side of the Form Design. To rename, you need to select on the control you want to change then take a look to the Property as example

            Sample of Controls which renamed

            For Button Add, please rename as btnAdd and for Listbox, please rename as ListValue. By Click on Form View, please see the result as below:

              Form View After Design

              To write the VBA programming, please select on Add button then right click after that select Build Event then Code Builder

                VBA Coding Panel

                By seeing this panel of coding, please copy as the below:

                Private Sub bntAdd_Click()
                Me.ListValue.RowSourceType = "Value List"
                Me.ListValue.AddItem (Me.txtvalue.Value)
                End Sub

                See the result below:

                  Result after Click on Add Button

                  Related post