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

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
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,216,225
Messages
6,129,604
Members
449,520
Latest member
TBFrieds

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