Using a Multi-select listbox to populate a DB field

  • Thread starter Thread starter mackdaddy
  • Start date Start date
M

mackdaddy

Guest
If anyone knows how to populate a field in a table from a multi-select listbox in the table's form, please let me know how. I am trying to capture everything selected in a string, which appears to be working, but it just refuses to populate the field in my table (the field is not even getting populated with the first or last selection made in the listbox). Any assistance anyone can offer would be greatly appreciated...
 
Hi MackDaddy,

I am not sure I understand what problem you are having.

You have loop through the items selected property of the list box. To store other values besides the bound column of the list box, you have to reference the column by index. Columns are zero-based, meaning 0 is the index for the first column, 1 is the index for the second column, etc)

This is how you reference the third column of multiple selections of a list box. Try this code on the Click event of a command button on your form to see what it does.

Dim ctl As Control
Dim varItm As Variant

Set ctl = Me.List10 'Put your list box name here!
For Each varItm In ctl.ItemsSelected
MsgBox ctl.Column(2, varItm)
'/// modify code here to store the right column, etc.
Next varItm


[This message has been edited by DML (edited 07-10-2000).]
 

Users who are viewing this thread

Back
Top Bottom