By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,483 Members | 3,312 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,483 IT Pros & Developers. It's quick & easy.

How do I Use a ';' Within the Value of a Column in a ComboBox or ListBox

100+
P: 759
Here is a "solution" to edit an item in a list (the example is for a list box but should work for a combo box too)
http://bytes.com/topic/access/answer...ox#post3711826

I make some "discoveries" trying to develop that code:

Is no way to add to a list box an item like this:
I am a coder; The best one !
When I try to add this item (using .AddItem method) to a list box with only one column, only first part (I am a coder) has been added. The second part has been lost.
For a list box with many columns this item is split: first part in first column, the second part in the second column.
So is it possible to add, in a single "cell" an item that contain the ";" sign ?

Another thing:
Is no way to deselect all items.
Somewhere I read that
Expand|Select|Wrap|Line Numbers
  1. ListBox = ""
should work.
Yes. This work until... an item in the list box is "". If this happen, this "empty" item will be selected.

Of course, as a human I can use this:
Expand|Select|Wrap|Line Numbers
  1. ListBox = "ThisStringNeverWillAppeareInMyListBox"
But as coder I can't be sure that even this "crazy" string will not appear at a moment.

If you have some solution to this problems please let me know.

Thank you !
Mar 26 '12 #1

✓ answered by Hennepin

Wrap the string with ; with quotes.
Expand|Select|Wrap|Line Numbers
  1. Me.List0.AddItem """I am a coder;The best one !"""

Share this Question
Share on Google+
10 Replies


NeoPa
Expert Mod 15k+
P: 31,494
If you look in the Help system (Context-Sensitive Help) you'll see that you can pass multiple values in a single string value with semi-colon (;) separators.
Mar 26 '12 #2

100+
P: 759
Yes, NeoPa. I know that.
My question is how to put a string that contain semi-colons in a single "cell" in a list box ? How to avoid that this string to be split ?
Mar 26 '12 #3

NeoPa
Expert Mod 15k+
P: 31,494
Sorry Mihail. I was confused by the question, but now I read it again it's clear that you did include that in the explanation. I read it badly.

Now, that's a good question. Help has nothing to say on the matter so I suggest you experiment with some of the typical 'string escape' characters (EG. '\'). Doubling up may be worth a try, but I'd guess that would simply result in an empty column value.
Mar 26 '12 #4

100+
P: 759
No problem, Adrian. Seems that my "English" is hard to understand even for you, an English guy.

I never have heard about 'string escape' characters.
I'll search on Google, of course, but if you are so kind to explain that in a little bit more details I'll thank you (again) very much.
Mar 26 '12 #5

NeoPa
Expert Mod 15k+
P: 31,494
Mihail:
No problem, Adrian. Seems that my "English" is hard to understand even for you, an English guy.
It's because I'm English, rather than in spite of it, Mihail ;-)

What I'm suggesting is simply to try :
Expand|Select|Wrap|Line Numbers
  1. "I am a coder\;The best one !"
Mar 27 '12 #6

100+
P: 759
Thank you !
No success.
Again 2 strings: I am a coder\ and The best one !

OK. I decide to not waste more time on this subject.
Thank you again !
Mar 27 '12 #7

P: 25
Wrap the string with ; with quotes.
Expand|Select|Wrap|Line Numbers
  1. Me.List0.AddItem """I am a coder;The best one !"""
Mar 27 '12 #8

NeoPa
Expert Mod 15k+
P: 31,494
Mihail:
OK. I decide to not waste more time on this subject.
That's lucky, because I'm out of ideas anyway :-D

If I find anything I'll post but basically, as of now, I have no idea if it's even possible :-(
Mar 27 '12 #9

NeoPa
Expert Mod 15k+
P: 31,494
Except that Hennepin has already provided a perfect answer. Nice one.
Mar 27 '12 #10

100+
P: 759
Indeed. It is the best answer.

Also I have verify this:
Expand|Select|Wrap|Line Numbers
  1. Me.List0.AddItem """I am a coder;The best one FirstColumn !"";""I am a coder;The best one SecondColumn !"""
for a list box with 2 columns and work perfect.

Thank you, Hennepin !
Mar 27 '12 #11

Post your reply

Sign in to post your reply or Sign up for a free account.