Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Multiselection saved to table?

cameling4funcameling4fun Member Posts: 1
I am creating a database to track classes and attendants. I want to create a multiselect listbox, and have it save to the table. Basically, this is what I have so far ( to keep it simple until I understand)

Relationships 1-many
class table
emp table

1 class to many employees.

Class table has classid#, date, instructor, time began, time ended as fields

Employee table has empid#, name, class#

I created a seperate table to just hold employees(students)names. I can get the listbox to list their names, but the multiselection does not save anywhere. I would like it to save in the employee table with name, class#.

Thank you,



  • dokken2dokken2 Member Posts: 532
    a multiselect listbox can not "bind" multiple selected values to the single field it is bound to, ie: you can't listen to 3 stations at the same time on a radio, you have to switch between them

    what you need to do-

    loop thru the listbox items
    determine if item is selected or not
    insert selected records into a table

    For i = 0 To Me.List0.ListCount - 1
    If Me.List0.Selected(i) Then MsgBox Me.List0.ItemData(i)
    Exit Sub

    Dim rec As String
    Dim sql As String
    For i = 0 To Me.List0.ListCount - 1

    If Me.List0.Selected(i) Then
    rec = Me.List0.ItemData(i)

    sql = "INSERT INTO Table2 ( PC_NAME )" & _
    " SELECT " & rec & " AS expr1;"
    DoCmd.SetWarnings False
    DoCmd.RunSQL sql
    DoCmd.SetWarnings True
    End If
Sign In or Register to comment.