Vba access: add addetem multicast to comma

I have a combobox with two columns, but the first one is hidden, which adds values ​​to the list the same way. I notice that the list box truncates the row in the second column.

This is my code so far, where cmbPart is a combobox and lstPart is a list.

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

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

How can I stop the behavior?

+5
source share
1 answer

Directly strings with commas to be added to the multi-column list must be enclosed in single quotes.

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

All Articles