Passing listbox values to a table

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a listbox on a form that I can select multiple values from, and place
them into a unbound field on the same form.
How do I pass these multiple values to the table?

Thanks
 
Hi Cuz,

Why not just bind the textbox to the field in question?

But in a properly normalised structure, you wouldn't be storing multiple
values in a single field anyway, but as related records in a separate
table. One commmon Access approach to this is, instead of a listbox, to
use a continuous subform bound to the related table, with a combobox in
the subform containing the list of available values.

If you do have to use a listbox, you need to do something like this
(pseudocode):

Open Recordset on the related table
With Recordset
For each varItem in TheListbox.ItemsSelected
.AddNew
.Fields(0).Value = Listbox.ItemData(varItem)
.Update
Next
End With
Recordset.Close
Set Recordset = Nothing
 
Back
Top