Multiselect Listbox to another Listbox - Urgent Help Please

G

Guest

Here is a summary of what I need help with. I have the following:
tblECR
ECRID - PK
ECRNumber - Text

tblECN
ECNID - PK
ECRsSelected - Text (listbox)

On the form "frmECN" I have an unbound listbox that does a query on tblECR
and lists all the ECRNumber entries into the listbox. I also have a listbox
on frmECN called ECRsSelected. Finally, I have a commandbutton that
"Copies" multiple values selected from the first listbox to the second
listbox (ECRsSelected). The code works in that I can get multiple selections
to the ECRsSelected listbox. The only problem is that it only stores the
first item and none of the others. I looked at the ECRsSelected field in the
actual table and it only shows one value. There is something missing from my
code. I cannot identify why I cannot get multiple values to be stored in the
ECRsSelected field in the table. Also, I need to clear the second listbox
(ECRsSelected) for the next record.

Here is my code. PLEASE HELP SOON. I have to show this to client by COB
Friday.


Dim ctrlListBox As ListBox
Dim FRM As Form, CTL As Control
Dim varitem As Variant
Dim strSQL As String
Set FRM = Forms![frmECN]
Set CTL = FRM!ECRNumber
Dim DB As Database
Set DB = CurrentDb
Set ctrlListBox = FRM!ECRsSelected

For Each varitem In CTL.ItemsSelected
ctrlListBox.AddItem Item:=CTL.ItemData(varitem)
Next

Thanks
Ben
 
G

Guest

So, are you trying to store multiple selections from a listbox so that those
items are automatically selected when you next go to that record?

Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top