Damn ampersand

L

Luke Bellamy

I have a label on a report that I set through VBA to be a user entered
value. When they put an ampersand (&) as the value the text in the
label shows up with the underscore (_) instead. I understand this but
I need to know how to escape the special chars so they show regardless.

Thanks
 
C

Cheryl Fischer

Hi Luke,

As you know, you have to use two & in a label or caption to have it display
a single &; i.e., to get Smith & Jones, you have to enter Smith && Jones.
So, how about after the user enters their label value, run it through the
Replace() function to replace & with &&?

regards,
 
V

Van T. Dinh

Put the user's input through the Replace() replacing "&" with "&&".

Alternatively, use a TextBox instead of a Label.
 
J

JohnFol

In this case you need &&. As simple way would be to use Replace(UserString,
"&", "&&")
 
Top