?
Solved

Additem to listbox containing a comma

Posted on 2003-03-14
9
Medium Priority
?
616 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
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 9

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

What Is Blockchain Technology?

Blockchain is a technology that underpins the success of Bitcoin and other digital currencies, but it has uses far beyond finance. Learn how blockchain works and why it is proving disruptive to other areas of IT.

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Suggested Courses

762 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