I have two multiselect listboxes.
I want the user to be able to make multiple selections in ListA (ListPerson) and multiple selections in ListB (Choice) then have these selections written to a table.
For example:
ListPerson
John
Jane
Bill
ListChoice
Choice 1
Choice 2
Choice 3
If John and Jane both have Choice 1 and Choice 2 selected then I would want the following records in the table
John Choice 1
John Choice 2
Jane Choice 1
Jane Choice 2
I am guessing this is some kind of nested for each loop but I have no clue where to start or how to achieve it?!
Dim db As DAO.Database
Dim Rs As DAO.Recordset
Dim ctl As Control
Dim varItem As Variant
Set db = CurrentDb()
Set Rs = db.OpenRecordset("tblChoicesMade", dbOpenDynaset, dbAppendOnly)
Set ctl = Me.ListPerson
For Each varItem In ctl.ItemsSelected
'Assuming I need some additional loop element here to cycle through the second multiselect listbox Me.ListChoice
Rs.AddNew
Rs!PersonID = ctl.Column(3, varItem)
Rs!ChoiceID = ctl.Column(3, varItem)
Rs.Update
Next varItem
I want the user to be able to make multiple selections in ListA (ListPerson) and multiple selections in ListB (Choice) then have these selections written to a table.
For example:
ListPerson
John
Jane
Bill
ListChoice
Choice 1
Choice 2
Choice 3
If John and Jane both have Choice 1 and Choice 2 selected then I would want the following records in the table
John Choice 1
John Choice 2
Jane Choice 1
Jane Choice 2
I am guessing this is some kind of nested for each loop but I have no clue where to start or how to achieve it?!
Dim db As DAO.Database
Dim Rs As DAO.Recordset
Dim ctl As Control
Dim varItem As Variant
Set db = CurrentDb()
Set Rs = db.OpenRecordset("tblChoicesMade", dbOpenDynaset, dbAppendOnly)
Set ctl = Me.ListPerson
For Each varItem In ctl.ItemsSelected
'Assuming I need some additional loop element here to cycle through the second multiselect listbox Me.ListChoice
Rs.AddNew
Rs!PersonID = ctl.Column(3, varItem)
Rs!ChoiceID = ctl.Column(3, varItem)
Rs.Update
Next varItem