Grab values from a Multi select listbox and save to a field. RRS feed

  • Question

  • Is there a way to save multiple selections from a list box and save to a field.  The client is insisting that  a list box be used..    Can this be done using VBA code. I have been searching without any success.

    olu Solaru

    Tuesday, June 11, 2019 7:47 PM

All replies

  • You can.  What I've done for this in the past is use a related take and use insert/delete queries to push pull the values.

    Another option would be to use multi-valued field, but I don't recommend it.  For purist they break database normalization and cause other headaches depending on what you need to do.

    Daniel Pineault, 2010-2018 Microsoft MVP
    Professional Support:
    MS Access Tips and Code Samples:

    Tuesday, June 11, 2019 9:15 PM
  • Take a look at in my public databases folder at:!169

    Note that if you are using an earlier version of Access you might find that the colour of some form objects such as buttons shows incorrectly and you will need to  amend the form design accordingly.

    This little demo file illustrates a number of interfaces, including the use of a multi-select list box to insert rows into or delete rows from the table which models the many-to-many relationship type between Students and Courses.

    However, I would strongly recommend the conventional interface of a form/subform for this.  It is code-free, and also allows the relationship type to include non-key attributes such as the Status attribute in my example.

    Ken Sheridan, Stafford, England

    Tuesday, June 11, 2019 10:17 PM
  • Hello Ken

    So I see you used a text box but made it look like a Listbox, am I correct? I was looking at frmStudent4.  

    olu Solaru

    Wednesday, June 12, 2019 2:53 PM
  • The 'using line separated list' example (frmStudents_4) uses a text box, but the 'using multi-select list box' example (frmStudents_1) uses a list box.  As noted in the demo the former was only added because some forum users asked for this specifically; it's not something I'd recommend.

    Ken Sheridan, Stafford, England

    Wednesday, June 12, 2019 5:24 PM