Listbox comma issues

balfoura

Registered User.
Local time
Yesterday, 23:26
Joined
Oct 3, 2008
Messages
30
on my form I have a combobox that will send any values (which are strings) clicked on to a listbox. i've gotten it to work fine except for when there are commas in the string. when there are commas in the string the commas act as a delimiter and break the string up onto multiple lines.

example: Ear, Nose, and Throat comes out as
Ear
Nose
and Throat
i've looked around and found alot of posts talking about the subject, but they don't seem to apply to my specific circumstances since i'm not typing in the string but am pulling it over from a combobox.

does anyone have any suggestions for getting around this? this database is going to be used to export info to a printed publication so i would like to keep the commas in if at all possible.

here is my code so far:

Private Sub cboSpec_Change()

lstSpec.AddItem cboSpec.Column(1)

End Sub

any help is greatly appreciated!
 
Try:
Code:
lstSpec.AddItem """" & cboSpec.Column(1) & """"
 
that worked!! thanks a bundle!!

may i ask why the four sets of quotes if you have an extra moment? just trying to make sense of it so i can hopefully figure this out for myself next time.
 
The first quotation mark is a begin-of-quoted-text marker to distinguish the text that follows as text, rather than part of the code. The next two consecutive quotation marks are then interpreted as a single quotation mark. Finally, the fourth quotation mark is the end-of-quoted-text marker.

Example:
? "He said, ""Hello,"" to which she responded with a smile."
He said, "Hello," to which she responded with a smile.
 
you can avoid the "" issue by instead using chr(34) (the " symbol) explicitly

so you can say eg in the where clause of a dlookup

"myfield = " & chr(34) & strvariable & chr(34)
 
The first quotation mark is a begin-of-quoted-text marker to distinguish the text that follows as text, rather than part of the code. The next two consecutive quotation marks are then interpreted as a single quotation mark. Finally, the fourth quotation mark is the end-of-quoted-text marker.

Example:
? "He said, ""Hello,"" to which she responded with a smile."
He said, "Hello," to which she responded with a smile.

thanks for the explanation!
 

Users who are viewing this thread

Back
Top Bottom