listbox addtiem question

D

Dave

I have 2 listboxes
Listbox2 is where the user selects the items that want to use (1 column)
extended listbox

ListBox4 is where the selected items are shown (1 column) extended listbox

I am using the additem method to populate listbox4 with the selected items
from listbox2

The problem I have run into is Listbox2 may have a value with a comma such as
"CABLE, TWISTED SHIELD 100 OHM"

when I use the additem method in listbox4 which must have the value field in
rowSourceType it breaks the value up from listbox2 into 2 seperate entries
such as

CABLE
TWISTED SHIELD 100 OHM

How do I prevent this from happening. Example Code Appreciated
Thanks in Advance
Dave


Code I am using:

Dim ctrlListBox As ListBox
Dim FRM As Form, CTl As Control
Dim varitem As Variant
Dim strSQL As String
Set FRM = Forms![FilterbyAccount/Description]
Set CTl = FRM!List2
Dim Db As Database
Set Db = CurrentDb
Set ctrlListBox = FRM!List4

'populate values in listbox4
For Each varitem In CTl.ItemsSelected

ctrlListBox.AddItem Item:=CTl.ItemData(varitem)

Next

'clears selected values in listbox2
For Each varitem In CTl.ItemsSelected

CTl.Selected(varitem) = False

Next varitem
 
S

Sandy

lstBox.additem(chr$(34) & strvalue & chr$(34))

chr$(34) is quotes and allows you to have comma's etc in your strings.

This should do it.

Sandy
 

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