Expression builder escape character?

jaybee3

Active Member
Joined
Jun 28, 2010
Messages
307
I'm trying to set up a default value for a text box. It will be a file path that contains an ampersand.

Everytime the form is loaded the text box evaluates the ampersand and so it disappears.

C:\J&B changes to C:\JB and so the subsequent code doesn't run.

Is there a way to escape the ampersand, like using a \ in other languages?



Thanks in advance
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
What exactly is the expression?

Have you tried using Chr(38)?
 
Upvote 0
Found the problem: When copying anything with an ampersand into the default value property, Access seemed to automatically evaluate it to the following:

Copied path:"H:\Q&C\Client\2013\Nov\"
Generated "expression": ="H:\Q" & "C\Client\2013\Nov\"

I first tried removing the '" ' and ' "' as per the original path, but it was having unexpected results, displaying the path as "H:\QC\Client\2013\Nov\"

Replaced the generated expression with: ="H:\Q" & Chr(38) & "C\Client\2013\Nov\" as per your suggestion and it works. Thanks :)

(On a side note, also then removed the '" & Chr(38) & "' and it now works as originally expected. Strange. but it works :S)
 
Upvote 0

Forum statistics

Threads
1,223,229
Messages
6,170,881
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top