Removing Apostrophe from an IF Statement in a name

  • Thread starter Thread starter ecwhite
  • Start date Start date
E

ecwhite

Please help me fix this, I am trying to remove the apostrophe in this name
but I am not getting it right.

This is the same Doc but name is typed differently so I am merging it.

Doc Groups: IIf([Doc]='O'Neill, Taylor F
' Or [Doc]='O'Neill R.Ph., Taylor F ',"O'Neill, Taylor F",[Doc])
 
You need to send the name out to a function:

Public Function ReplaceChr(ByVal theString As String) As String

Dim strTemp As String

strTemp = Replace(theString, "'", "''")
ReplaceChr = strTemp

End Function
 
ecwhite said:
Please help me fix this, I am trying to remove the apostrophe in this
name but I am not getting it right.

This is the same Doc but name is typed differently so I am merging it.

Doc Groups: IIf([Doc]='O'Neill, Taylor F
' Or [Doc]='O'Neill R.Ph., Taylor F ',"O'Neill, Taylor F",[Doc])
If you delimit a string with apostrophes, you have to escape the literal
apostrophes within the string by doubling them. In this case, it would
be simpler to just use quotes to delimit the strings:

Doc Groups: IIf([Doc]="O'Neill, Taylor F" Or [Doc]="O'Neill R.Ph.,
Taylor F ","O'Neill, Taylor F",[Doc])

if you insist on using apostrophes (single quotes) as delimiters, then
double the apostrophe"
Doc Groups: IIf([Doc]='O''Neill, Taylor F' Or [Doc]='O''Neill R.Ph.,
Taylor F ',"O'Neill, Taylor F",[Doc])
 
When there is an embedded single quote, you must either double it (two
single quotes, not a single "double quote") or enclose the string between
double quotes:

Doc Groups: IIf([Doc]='O''Neill, Taylor F' Or [Doc]='O''Neill R.Ph., Taylor
F',"O'Neill, Taylor F",[Doc])

You can use something like:

s = Replace (s, "'", "''")

or:
s = Replace (s, '''', '''''')

or:
s = Replace (s, Chr(39), Chr(39) & Chr(39))

In the same way, if it's a double quote that is enclosed between two double
quotes, you use single quote to delimit your string or replace the embedded
double quote with two double quotes:

s = Replace (s, '"', '""')

or:
s = Replace (s, """", """""")

or:
s = Replace (s, Chr(34), Chr(34) & Chr(34))

You must also take cares about blank space as the two ones that you have put
after the first two Taylor F.
 
Thank you all, I have got the two examples to work and I am very greatful for
everyone's time and help.

Bob Barrows said:
ecwhite said:
Please help me fix this, I am trying to remove the apostrophe in this
name but I am not getting it right.

This is the same Doc but name is typed differently so I am merging it.

Doc Groups: IIf([Doc]='O'Neill, Taylor F
' Or [Doc]='O'Neill R.Ph., Taylor F ',"O'Neill, Taylor F",[Doc])
If you delimit a string with apostrophes, you have to escape the literal
apostrophes within the string by doubling them. In this case, it would
be simpler to just use quotes to delimit the strings:

Doc Groups: IIf([Doc]="O'Neill, Taylor F" Or [Doc]="O'Neill R.Ph.,
Taylor F ","O'Neill, Taylor F",[Doc])

if you insist on using apostrophes (single quotes) as delimiters, then
double the apostrophe"
Doc Groups: IIf([Doc]='O''Neill, Taylor F' Or [Doc]='O''Neill R.Ph.,
Taylor F ',"O'Neill, Taylor F",[Doc])
 
Back
Top