Problems storing lists into a table

  • Thread starter Thread starter ScottK
  • Start date Start date
S

ScottK

I have a list box that you can select multiple items,
which you can then copy over to a standard text box by
clicking on a command button. I need to store all those
items that have been copied to the text box into a table
for future reference. I have assigned a control source to
the text box, but it still will not the data over to the
assigned table. Any help be great. Thanks.

Scott
 
Your list box should be unbound (no control source), and
as you said, your text box should be bound to the field
that will store the string of values. The command button
OnClick() event should resemble this...

Private Sub MyButton_Click()
Dim var As Variant
Dim ctl As ListBox
Dim str As String
Set ctl = Me!lstListBox
For Each var In ctl.ItemsSelected
str = str & ";" & ctl.ItemData(var)
Next var
str = Mid(str, 2)
Me!txtTextBox = str
Set ctl = Nothing
End Sub

Be sure the record has been saved before you look at the
table to see if it worked. Good luck.
 
Back
Top