Strange reaction to "&" character (1 Viewer)

Fear Naught

Kevin
Local time
Today, 19:52
Joined
Mar 2, 2006
Messages
229
I make the caption on a button change for each record in my recordset.

I want it to read Print Report for [Customer Name]. This is easy with the code cmdReport.Caption = "Print Report for " & [CustomerName] and it works unless the customer name has an "&" in it then the character displays as an underscore

So examples.

Customer name equals Acme Corporation then the button displays

Print Report for Acme Corporation

However is customer name equals Bloggs & Bloggs Corporation the button displays:

Print Report for Bloggs _ Bloggs Corporation.

Does anybody know how to get round this?
 
You have two have two && if you want one & to show as the caption of your command button.
 
But the "&" that doesn't show up is embedded in the field [CustomerName]. Where would I put the two &&.

I need to be a command button so that it prints a report.
 
You will have to use the Replace() function to find & and replace it with && [test if the & exists].
 
ghudson said:
You have two have two && if you want one & to show as the caption of your command button.

Hi Ghudson,


Does the double ampersand (&&) work anywhere that I get an error "Shortcut is not available now", or something like that. Specifically, I have tried to use the ampersand in the caption of tabs on forms e.g. "Projects & assets".

This isn't a big thing as I use the "+" instead, but I would prefer to use the "&".

Regards,


Keith.
 
Keith Nichols said:
Does the double ampersand (&&) work anywhere that I get an error "Shortcut is not available now", or something like that. Specifically, I have tried to use the ampersand in the caption of tabs on forms e.g. "Projects & assets".
I do not understand your question [problem].
 
ghudson said:
I do not understand your question [problem].

Hi Ghudson,

I have re-read my post and realise I had garbled it a bit. Sorry.

On a page of a tabbed form I had 2 subforms dealing with different information and wanted to use the ampersand in the tab caption e.g. "Management & User Comments". However, the & generates an underscore rather than the desired &. I have just tested the && and it works fine showing a single &.

In other instances at my office, when I tried to use & within the quotation marks of a text box expression, I would get a report along the lines of "The keyboard shortcut is not available here". Something like =[department]&" Projects "&" & Personnel".

I have tried to replicate this error at home but it doesn't seem to be a problem here. Anyway, the double ampersand does result in a sigle ampersand showing.

From this error message I deduce that somehow you can set a keyboard shortcut using the ampersand although I can't find anything to explain it in the Access help or Access VB help. It isn't something I particularly want to do, so I have answered my own question really. I have a vague recollection that this is how you set a keyboard shortcut to a menu command in Word or Excell.

Many thanks.

Keith.
 
Yes, the & will preceed a letter to be the keyboard shortcut key for command buttons.
 
Fear Naught said:
I make the caption on a button change for each record in my recordset.

I want it to read Print Report for [Customer Name]. This is easy with the code cmdReport.Caption = "Print Report for " & [CustomerName] and it works unless the customer name has an "&" in it then the character displays as an underscore

...

Where would one put that specific code? I'm trying to do a similar thing, but for the page tab name on a form. I have tried the code under form_onconnect and that doesn't work.

Thanks!
 

Users who are viewing this thread

Back
Top Bottom