Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2003
    Posts
    34

    Unanswered: Idly confused by triple quotes

    No emergency here; I was just wondering about something, and thought I'd babble about it here.

    I know how to use triple quotes in sql expressions in VBA in order to prevent errors with apostrophes and the like:

    randomsql = "SELECT Datum from tblData WHERE Identity = """ & RandomString & """;"

    It just always bugs me when I know something works, but not WHY it works. I keep looking at those nested apostrophes and I can't make sense of them. It's like you go out of randomsql, then back in again, then... or maybe not? And why aren't there more &'s in there?

    *confoozled*

    If any of you gurus have time to waste, pray enlighten me. Thanks much.

  2. #2
    Join Date
    Feb 2004
    Location
    Dorset UK
    Posts
    147
    Im not a guru, but I'll have a crack at this..

    Micorsoft say

    basically they say :
    One of the three is a delimiter.
    The other two are seen as one double quotation mark to search for in the literal string.


    So I reckon they mean..

    i) a single set of " means you are using a numeric value.

    These are literal strings from now on...

    ii) double " means you are using whatever you type between these.
    iii) triple " means you are entering a text value.

    You could always look at this, but it might confuse you more, I looked at it once and my head hurt for 3 hours, 1 eye still flickers...

    http://support.microsoft.com/default...b;EN-US;147687



    Hope I haven't confused you more.

    Ken

  3. #3
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    The way double quotes are interpreted are:

    First " is the beginning of the string

    Any "" within the string is considered a literal "

    Last " is the end of the string.

    So if you wanted to see:

    Double "Quotes" In Action

    You need a string like:

    "Double ""Quotes"" In Action"

    Even though I understand how to use them I still prefer to use single quotes when possible. Think "'" is easier to read then """" when you are enclosing a parameter in double quotes.

  4. #4
    Join Date
    Oct 2003
    Posts
    34
    There's a slightly more coherent article here:

    http://msdn.microsoft.com/library/de...sInStrings.asp

    In which it is explained that two double quotes is parsed as one single quote (as opposed to one double quote).

    Bizarre.

  5. #5
    Join Date
    Feb 2004
    Location
    Dorset UK
    Posts
    147
    Please stop or I'll go blind !

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •