Commas and Semi-colons in comboboxes

  • Thread starter Thread starter Dirkasaurus
  • Start date Start date
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
 
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.
 
A slight correction:

Me.Combo1.RowSource = Chr(34) & "Doe, John" & Chr(34) & "," & Chr(34) &
"Brown, Mary" & Chr(34) & "," & Chr(34) & "Smith, Jim" & Chr(34)
 
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"
 
Back
Top