How to Add Multi Column Data to Listbox Access

Written by jaime avelar
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Add Multi Column Data to Listbox Access
Learn how to add data to a list box in Access using VBA. (background with binary data image by Pedro Nogueira from Fotolia.com)

Access is a relational database management system included in the Microsoft Office suite that is commonly used for smaller local databases. Knowing how to populate a list box in Microsoft Office Access can save you time when you need to display data. A list box control can be used to display data from a table through a Graphical User Interface or GUI. Visual Basic for Applications is a computer programming language that can be used for this task.

Skill level:
Moderate

Other People Are Reading

Instructions

  1. 1

    Start Microsoft Office Access 2007 and select "Blank Database" then click "Create."

  2. 2

    Select the "Create" tab and select "Form Design" to create a new form. Click "Button" on the "Controls" then left-click your form and drag to create a new button. Add a "List Box" control the same way you added the button.

  3. 3

    Right-click "List0", select "Properties" and click the "All" tab. Type "2" next to "Column Count". Select the "Data" tab and type "Value List" next to "Row Source Type."

  4. 4

    Right-click "Command0" and select "Properties". Click the "Event" tab and select "[Event Procedure]" next to "On Click". Click the ellipsis (...) to open the "Microsoft Visual Basic" Window.

    Press "Ctrl" and "A" and press "Delete" to remove existing code.

  5. 5

    Copy and paste the following code into your module. This code will add data to both columns in your list box control.

    Option Compare Database

    Private Sub Command0_Click()

    Dim dataToWrite As String

    dataToWrite = "Column 1 - Row 1; Column 2 - Row 1; "

    dataToWrite = dataToWrite & "Column 1 - Row 2; Column 2 - Row 2"

    Me.List0.RowSource = dataToWrite

    End Sub

  6. 6

    Close the "Microsoft Visual Basic" Window and right-click "Form1" then select "Form View". Click "Command0" to execute your code.

Don't Miss

Filter:
  • All types
  • Articles
  • Slideshows
  • Videos
Sort:
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the eHow.co.uk site, you consent to the use of cookies. For more information, please see our Cookie policy.