Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2003
    Posts
    123

    Red face Unanswered: Adding the contents of a listbox to a table

    I have a form where users click Add and Remove buttons to add items to a list box. When they click a "Save" button, I want to cycle through each item in the list and save it to a table.

    Take a book title and chapters as an example:

    Book title typed into textbox
    Chapters added to listbox Chapter 1
    Chapter 2
    Chapter 3

    When they click "Save", I want to add records to a table for each Chapter that was put into the listbox. I tried something like:

    For Each varItem In ListBox
    Code for adding single record...
    Next

    But that didn't work. Is there some other way that would turn the items in a listbox into a record set or something?

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    You might poke around here for "multiselect". The code might look more like this:

    For Each varItem In ctl.ItemsSelected

    where ctl is a variable for the listbox.
    Paul

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •