Commas in list box items

G

Guest

I am populating a list box from values in a table. One of the table values,
a text field, may or may not contain commas (,). When a comma is
encountered, the list box acts as if it is a semi-colon (;), treating the
comma as a delimiter. Is there a workaround?

Thanks in advance
 
D

David C. Holley

How are you populting the list box? Are you populating it from a
Table/Query? Commas in a field value are possible.

David H
 
G

Guest

I am using a table, running a SELECT query and populating it from the
recordset using the AddItem method.
 
A

Alex Dybenko

why not to bind query directly to combobox? set rowsource type to
Table/Query and row source to your query
 
D

David C. Holley

If there's no special logic that you're exerting on the field values
using VBA, change the RowSourceType to Table/Query and set the RowSource
to the Query.

David H
 
G

Guest

Alex:

I need to customize the list box. The only problem I have is when the text
contains a comma. It is then treated as a delimiter. All I am looking for
is an easy workaround, if possible. I have to use List Values as my
rowsource type to be able to add the custom selection(s), so binding it to a
table/query is not feasible.

Spaseeba.
 
D

David C. Holley

Could you please elaborate on how you need to customize the list box?
More likely than not the customization is possible at the query level.

David H
 
J

John Nurick

Hi Andy,

Have you tried enclosing the values in quotes?

"first";"second,comma";"third"
 
G

Guest

John:

Thanks for your suggestion. I had read that suggestion under another thread
and had tried it with no success.
 
J

John Nurick

Curious. It works when I try it (Access 2003, Win XP, regional settings
English UK). This is pasted from one of my comboboxes' RowSource
property:
"test";"with; colon";"with, comma";"without";unquoted
and it displays as
test
with; colon
with, commma
without
unquoted

Alternatives: as David H suggests, write a query to customise the list
contents; or write code that strips out the commas. Possibly you could
substitute "‚" the "single low-9 quotation mark", which is at 0x082 in
western European character sets, or U+201A in Unicode.
 
D

David C. Holley

Could you please elaborate on how you need to customize the list box?
More likely than not the customization is possible at the query level.
The technique that you are currently using obviously isn't working. If
you share with us the big picture, we should be able to come up with a
solution for you.

David H
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top