Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Apostrophe issue 1

Status
Not open for further replies.

crossface

Programmer
Nov 30, 2002
81
US
The following code is giving me a problem due to the apostrophe in the string

Command contains unrecognized phrase/keyword

Name=='This is Mary's book'


How can I resolve this problem?

 
I am using the with a string &AppendedString The double quotes don't work
 
Here is my code that is having the issue

TempSelectedName=ALLTRIM(SelectedName)

AppendedString= "ALLTRIM(" + FirstField + ")=='" + TempSelectedName + "'"


replace ALL selected WITH .t. FOR &AppendedString


If SelectedName has an apostrophe in the string I get the error
 

If your string can contain an apostrophe, don't use also apostrophes to enclose it (as you do it in your code). Use quotation marks or square brackets. Like this:

Code:
TempSelectedName=ALLTRIM(SelectedName)

AppendedString=[ALLTRIM(]+FirstField+[)=="]+ TempSelectedName+["]

replace ALL selected WITH .t. FOR &AppendedString

OR

Code:
TempSelectedName=ALLTRIM(SelectedName)

AppendedString="ALLTRIM("+FirstField+")==["+TempSelectedName+"]"

replace ALL selected WITH .t. FOR &AppendedString
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top