Commas and Semi-colons in comboboxes

D

Dirkasaurus

Does anyone know some type of work around or a variable setting that allows
MSAccess combos to not treat commas or Semicolons as carriage returns?

If the combo gets its data from a MS Table it can handle Commas or semi
colons, but if it gets it from string values via code that MSAccess treats
them as carriage returns and breaks of the data accorddingly.

Any suggestions?
Thanks
 
C

Cheryl Fischer

If you must handle this in code for a combo or list box with its Row Source
Type set to "Value List", you will need to insert quotation marks around
each value explicitly:

Me.Combo1.RowSource = Chr(34) & "Doe, John" & Chr(34) & "," & Chr(34) &
"Brown, Mary" & Chr(34) & "," & Chr(34)

It is lots less work to do this using a table or query into the table (to
update the RowSource) as the Row Source for a combo or list box.
 
C

Cheryl Fischer

A slight correction:

Me.Combo1.RowSource = Chr(34) & "Doe, John" & Chr(34) & "," & Chr(34) &
"Brown, Mary" & Chr(34) & "," & Chr(34) & "Smith, Jim" & Chr(34)
 
D

Dirk Goldgar

Dirkasaurus said:
Does anyone know some type of work around or a variable setting that
allows MSAccess combos to not treat commas or Semicolons as carriage
returns?

If the combo gets its data from a MS Table it can handle Commas or
semi colons, but if it gets it from string values via code that
MSAccess treats them as carriage returns and breaks of the data
accorddingly.

Are you talking about setting the combo box's RowSource to a value list?
You have to enclose any values that include commas or semicolons in
quotes. If you're setting the RowSource property on the property sheet,
you could do it as in this example:

Row Source ......... A; "B; C"; "D, E", F

If you're setting the property in code, you need to use quoted strings
*inside* the quoted string literal. Here's an example:

Me.List0.RowSource = "A; 'B; C'; 'D, E', F"

You can also get internal quotes by doubling up the double-quotes:

Me.List0.RowSource = "A; ""B; C""; ""D, E"", F"
 

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