[AccessD] FW: CodeL

Arthur Fuller fuller.artful at gmail.com
Fri Mar 7 16:28:49 CST 2008


If you do both Replace() calls, yes, and the count of occurrences is
irrelevant since it replaces them all.

Arthur

On 3/7/08, Eric Starkenburg <eric.starkenburg at home.nl> wrote:
>
> Arthur,
>
> Does this work when both characters exist in one sentence?
> Maybe the single quote once and two double quotes.
>
>
>
> Regards,
> Eric
>
>
> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com
>
> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Arthur Fuller
> Sent: Friday, March 07, 2008 11:07 PM
> To: Access Developers discussion and problem solving
> Subject: Re: [AccessD] FW: CodeL
>
> This is overkill, I think, Eric. You just have to know how to handle SQL
> containing either single or double quotes or neither. It's quite
> straightforward, really. You can eliminate all the hassle for any column
> that might contain these values by doubling up on the single and double
> quotes, which you can do in exactly one statement each:
>
> Replace( [columnName], Chr(39), (Chr(39) & Chr(39) )
> and similarly
> Replace( [columnName], Chr(34), (Chr(34) & Chr(34) )
>
> You can wrap both calls into a function if you wish. The code does nothing
> on values that don't contain the offending characters.
>
> Having been bitten by surnames like O'Hara and embedded quotations, if I
> suspect that this might ever occur, I just pre-empt it right from the
> beginning.
>
> hth,
> Arthur
>



More information about the AccessD mailing list