Happy New Year folks,
I have a form showing a certain source type. On this form I have a sub form which shows all categories available to this source type.
The sub form is set up with two list boxes one showing available categories but not yet assigned to this source type(lst1); the other list box shows categories currently assigned to this source type(lst2).
There are two command Buttons between the list boxes; the user selects an item in lst1 clicks the assign button and the category becomes assigned and moves to lst2 and is removed from lst1 and vice versa.
This all works perfectly for single selections, I assign the selection key field to a VBA variable and use an ADODB command + SQL statement to add this directly to the tbl and requery lst1 and lst2.
My problem is acheiving the same with multi selections. I think I need to assign these to an array with the number of elements governed by the ItemsSelected property of the multi select lst and each key an element of the array.
Can any one help me with the code to set up this array, assign the Cat Key field to array elements and loop through this to create an ADODB recordset object or command of the Items selected in the list box.
It is only this step of in the code that is causing me problems - going from multi selections to a recordset - once into a rst the rest is simple.
Thanks for your help
Jon (VBA Novice)
BTW (using Access 2002)
I have a form showing a certain source type. On this form I have a sub form which shows all categories available to this source type.
The sub form is set up with two list boxes one showing available categories but not yet assigned to this source type(lst1); the other list box shows categories currently assigned to this source type(lst2).
There are two command Buttons between the list boxes; the user selects an item in lst1 clicks the assign button and the category becomes assigned and moves to lst2 and is removed from lst1 and vice versa.
This all works perfectly for single selections, I assign the selection key field to a VBA variable and use an ADODB command + SQL statement to add this directly to the tbl and requery lst1 and lst2.
My problem is acheiving the same with multi selections. I think I need to assign these to an array with the number of elements governed by the ItemsSelected property of the multi select lst and each key an element of the array.
Can any one help me with the code to set up this array, assign the Cat Key field to array elements and loop through this to create an ADODB recordset object or command of the Items selected in the list box.
It is only this step of in the code that is causing me problems - going from multi selections to a recordset - once into a rst the rest is simple.
Thanks for your help
Jon (VBA Novice)
BTW (using Access 2002)