Issue Opening form when special character involved (1 Viewer)

mkdrep

Registered User.
Local time
Yesterday, 22:52
Joined
Feb 6, 2014
Messages
176
I previously had an issue using a button to open a form when the Customer name had an "&" special character in it's name, i.e. Jones & Sons. I solved that by writing following code:

stLinkCriteria = "[ EUContact]=" & Chr(34) & Me![ EUContact] & Chr(34)

I have run into the same issue when the Customer has an apostrophe in it's name, i.e. St. John's Church.

For the life of me, I can not find the Chr # that represents an apostrophe. Does anyone know what that might be? Also, how would I write the code to cover both instances.... "&" and " ' "......

Thank you......Mark
 

CJ_London

Super Moderator
Staff member
Local time
Today, 03:52
Joined
Feb 19, 2013
Messages
16,607
you need to replace a single apostrophe with 2 singles

stklinkcriteria=replace(eucontact,"'","''")
 

CJ_London

Super Moderator
Staff member
Local time
Today, 03:52
Joined
Feb 19, 2013
Messages
16,607
PS - I've never had a problem with an ampersand being in a name and looks like your allocation is incorrect for a string

try

stLinkCriteria = "[ EUContact]='" replace(Me![ EUContact],"'","''") & "'"

or

stLinkCriteria = "[ EUContact]=""" replace(Me![ EUContact],"'","''") & """"
 

MarkK

bit cruncher
Local time
Yesterday, 19:52
Joined
Mar 17, 2004
Messages
8,179
But this also reveals the inherent vulnerabilities and complications of not working with Long Integer key fields in your code. Provide your user with text selection tools, (Combos, Listboxes, and so on) but then render that down to the selected ID. Then use that ID in your code.
 

mkdrep

Registered User.
Local time
Yesterday, 22:52
Joined
Feb 6, 2014
Messages
176
But this also reveals the inherent vulnerabilities and complications of not working with Long Integer key fields in your code. Provide your user with text selection tools, (Combos, Listboxes, and so on) but then render that down to the selected ID. Then use that ID in your code.

Unfortunately, I started developing this program back in the early 2000's when I was just a "rookie" and didn't realize all the issues this would cause me in the future. I do have a few "work-arounds" like this to keep things working relatively smoothly.

Now if I only had about 1,000 hours of free time to rework this program! lol

Regards...........Mark
 

Users who are viewing this thread

Top Bottom