Hi
I have the following line of code:
ctrlListBox.AddItem Item:=strItem
However, where the value of strItem contains a comma, such as KOREA,
DEMOCRATIC PEOPLE'S REP, it comes out as two separate items, KOREA and
DEMOCRATIC PEOPLE'S REP.
Why is this? How can I prevent it?
Stapes
Dirk Goldgar - 18 Dec 2007 16:01 GMT
> Hi
>
[quoted text clipped - 7 lines]
>
> Why is this? How can I prevent it?
Because the list box uses the comma as a value-separator in its rowsource,
you must enclose the value to be added in quotes (single or double) when you
add it, if it contains (or may contain) a comma:
ctrlListBox.AddItem Item:=Chr(34) & strItem & Chr(34)

Signature
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)