Access VBA Adding items to ListBox issue

Hi

In my Access VBA code I use the following line to add a row to a ListBox
Me.ListBox1.AddItem oDescription & ";" & oUnits

Id the variable oDescription has a colon or semi-colon in it this causes problems
How do I get around this?

Thanks
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAsked:
Who is Participating?
 
Gustav BrockConnect With a Mentor CIOCommented:
You could wrap it in double-quotes to tell that this is one string:

Me.ListBox1.AddItem Chr(34) & oDescription & Chr(34) & ";" & oUnits

Open in new window

0
 
Rgonzo1971Connect With a Mentor Commented:
Hi,

pls try
Chr(34) & oDescription & ";" & oUnits & Chr(34)

Open in new window

Regards
0
 
Rgonzo1971Connect With a Mentor Commented:
Corrected code
Chr(34) & oDescription & Chr(34) & ";" & oUnits 

Open in new window

0
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks very much
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.