Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access vba: listbox additem multicolumn truncating on comma

Tags:

vba

ms-access

I have a combobox with two colunms, but the first is hidden that adds values onto a listbox in the same manner. I am noticing that the list box is truncating the string in the second column.

This is my code thus far where cmbPart is the combobox and lstPart is the listbox.

Me.lstPart.AddItem (CStr(Me.cmbPart.Value) & " ;" & CStr(Me.cmbPart.Column(1, Me.cmbPart.ListIndex)))

I notice that that when there is a comma (,) in the string it stops displaying the rest from Me.cmbPart.Column(1, Me.cmbPart.ListIndex).

How can I stop the behavior?

like image 875
Rick Avatar asked Oct 13 '11 02:10

Rick


1 Answers

Aperently strings with commas in to be added to a multicolunm listbox bust be enclosed in single quotes.

Me.lstPart.AddItem (CStr(Me.cmbPart.Value) & " ;" & CStr("'" & Me.cmbPart.Column(1, Me.cmbPart.ListIndex)) & "'")
like image 107
Rick Avatar answered Sep 30 '22 17:09

Rick