How to display user entered character "&"

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

On a MS Access form, I would like to display user entered text on a label
control.

However, the character "&" supplied by the user does not get displayed on
the label control, instead, an underline character "_" is displayed. Any
ideas?

For example, I have tested with an user entered string and display it on a
label control.
''''''''''''''''''''''''''''''
Me.lblTZ_Name.Caption = "Task Name: " & "abc & xyz"
''''''''''''''''''''''''''''''
However, the Form displays "Task Name: abc_xyz"
 
Double up the "&" character:

Me.lblTZ_Name.Caption = "Task Name: " & "abc && xyz"

If you're getting the value from a user (say, by a text box control), then
use Replace function to double up the character:

Me.lblTZ_Name.Caption = "Task Name: " & Replace(Me.TextBoxName.Value, _
"&", "&&", 1, -1, vbTextCompare)
 
On a MS Access form, I would like to display user entered text on a label
control.

However, the character "&" supplied by the user does not get displayed on
the label control, instead, an underline character "_" is displayed. Any
ideas?

For example, I have tested with an user entered string and display it on a
label control.
''''''''''''''''''''''''''''''
Me.lblTZ_Name.Caption = "Task Name: " & "abc & xyz"
''''''''''''''''''''''''''''''
However, the Form displays "Task Name: abc_xyz"

The & character in a label defines the *next* character as a hotkey,
and displays it underlined; for example, you can have a button labeled
E&xit. It will display with the x underlined, and typing Alt-X will
"push" the button.

To actually display an ampersand, double it up:

Me.lblTZ_Name.Caption = "Task Name: " & "abc && xyz"

or to accept user input, say from the form control txtTaskLabel,

Me.lblTZ_Name.Caption = "Task Name: " & Replace(Me!txtTaskLabel, "&",
"&&")

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
Thanks for your information.

Ken Snell said:
Double up the "&" character:

Me.lblTZ_Name.Caption = "Task Name: " & "abc && xyz"

If you're getting the value from a user (say, by a text box control), then
use Replace function to double up the character:

Me.lblTZ_Name.Caption = "Task Name: " & Replace(Me.TextBoxName.Value, _
"&", "&&", 1, -1, vbTextCompare)
 
Thanks for your information.

John Vinson said:
The & character in a label defines the *next* character as a hotkey,
and displays it underlined; for example, you can have a button labeled
E&xit. It will display with the x underlined, and typing Alt-X will
"push" the button.

To actually display an ampersand, double it up:

Me.lblTZ_Name.Caption = "Task Name: " & "abc && xyz"

or to accept user input, say from the form control txtTaskLabel,

Me.lblTZ_Name.Caption = "Task Name: " & Replace(Me!txtTaskLabel, "&",
"&&")

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
Back
Top