?
Solved

Additem to listbox containing a comma

Posted on 2003-03-14
9
Medium Priority
?
619 Views
Last Modified: 2010-06-03
I have a value list in Access 2002 that I'm adding strings to with the additem method.  The strings that contain commas get treated like two separate entries, but I want to them as one.

Is there an easy way to do this?
0
Comment
Question by:Plamodo
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 4

Expert Comment

by:bistrica
ID: 8136515
try with asci representation for comma like:
abcd & chr(COMMA) & efg

where COMMA is numeric value for comma.
0
 
LVL 6

Author Comment

by:Plamodo
ID: 8136587
So, I should perform some sort of a replace routine on the string in question to replace all "," with          chr(COMMA) .. and then do the additem to the new string?

0
 
LVL 6

Author Comment

by:Plamodo
ID: 8136601
So, I should perform some sort of a replace routine on the string in question to replace all "," with          chr(COMMA) .. and then do the additem to the new string?

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:bistrica
ID: 8136707
Yes, that's my suggestion.
0
 
LVL 6

Author Comment

by:Plamodo
ID: 8136716
The chr(COMMA) returned an error not recognizing the COMMA part.
0
 
LVL 41

Accepted Solution

by:
shanesuebsahakarn earned 200 total points
ID: 8136752
That won't work.

You will need to delimit your entries with the text delimiter. For example, if you have:
MyCombo.AddItem "Some,text"

You'll need to change it to either:
MyCombo.AddItem """Some,text""" (preferable)
or:
MyCombo.AddItem "'Some,text'"

If it is a field or value:
MyCombo.AddItem Chr(34) & strSomeVariable & Chr(34)
0
 
LVL 6

Author Comment

by:Plamodo
ID: 8136797
shanesuebsahakam, you did it again!

Thank so much.  I think I owe you a beer or two by now.
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 8136990
NP, glad I could help!
0
 
LVL 11

Expert Comment

by:Neil Fleming
ID: 26534744
Note that if you do this, and the text you are adding also happens to contain some double quote marks, you WILL need to convert those, or the text will cut off at the first quote mark:

If you are listing the actions assigned to commandbutton controls, for instance, then you need:

For Each cmbButton In cmbControl.Controls
'replace double quotes with DOUBLE double quotes:
SomeAction = Replace(cmbButton.onAction, """", """""")
'add to listbox:
.AddItem (cmbButton.Caption & ";" & """" & SomeAction & """")

This will correctly display in the Listbox as, eg:
&Customers: =openform("frmCustomers",0)

..with quotes and commas and all. Without the conversion you will get just:
&Customers: =openform(
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question