Results 1 to 5 of 5
  1. #1
    shurstgbr is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    2

    Quotation Mark Hell

    I have a database where one of the fields contains the inch symbol ("). e.g. 02"-GP-1734-E17-N. However, I am trying to create an sql string in a module with a where clause based on the above field. The query sql is SELECT FINAL.ItemID, FINAL.*


    FROM FINAL
    WHERE (((FINAL.ItemID)="02""-GP-1734-E17-N"))
    ORDER BY FINAL.ItemID;

    but what do I have to do to make this work in a module as I am entering quotation mark hell!!!

    Thanks in advance

  2. #2
    SoftwareMatters is offline Access VBA Developers
    Windows XP Access 2003
    Join Date
    Mar 2009
    Location
    Dorset
    Posts
    274
    I would probably do a find/replace and change the quotes to something else like `` then you won't have a problem.

  3. #3
    shurstgbr is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    2
    JD

    Yeah I have thought about that and clearly that would work but what I really want to know is how to do it "properly" (or should that be ""properly""!).

  4. #4
    jgelpi16 is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    Quote Originally Posted by shurstgbr View Post
    I have a database where one of the fields contains the inch symbol ("). e.g. 02"-GP-1734-E17-N. However, I am trying to create an sql string in a module with a where clause based on the above field. The query sql is SELECT FINAL.ItemID, FINAL.*
    FROM FINAL
    WHERE (((FINAL.ItemID)="02""-GP-1734-E17-N"))
    ORDER BY FINAL.ItemID;

    but what do I have to do to make this work in a module as I am entering quotation mark hell!!!

    Thanks in advance
    I know this is hell. I have fought this battle several times...Have you tried assigning the value to a variable first?
    Code:
    strCriteria = "02""
    SELECT FINAL.ItemID, FINAL.*
    FROM FINAL
    WHERE (((FINAL.ItemID)='" & strCriteria & "' & "-GP-1734-E17-N"))
    ORDER BY FINAL.ItemID;
    Would it be possible to replace the " with a ' ? I know you can replace a ' with '' (two single quotes) and SQL will treat that has a '.
    Code:
    strCriteria = "02""
    strCriteria = Replace(strCriteria, "'", "''")
    SELECT FINAL.ItemID, FINAL.*
    FROM FINAL
    WHERE (((FINAL.ItemID)='" & strCriteria & "' & "-GP-1734-E17-N"))
    ORDER BY FINAL.ItemID;
    Did you try surrounding the double-quote in double-quotes? (""").
    Code:
    strCriteria = "02""""
    SELECT FINAL.ItemID, FINAL.*
    FROM FINAL
    WHERE (((FINAL.ItemID)='" & strCriteria & "' & "-GP-1734-E17-N"))
    ORDER BY FINAL.ItemID;

  5. #5
    jgelpi16 is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    Quote Originally Posted by shurstgbr View Post
    JD

    Yeah I have thought about that and clearly that would work but what I really want to know is how to do it "properly" (or should that be ""properly""!).
    Try the below link....

    http://www.access-programmers.co.uk/...ad.php?t=87132

Please reply to this thread with any new information or opinions.

Similar Threads

  1. How to mark a thread as solved
    By Matrix in forum Forum Suggestions
    Replies: 10
    Last Post: 12-12-2019, 06:55 AM
  2. Concatenate Quotation Marks
    By millerdav99 in forum Programming
    Replies: 3
    Last Post: 04-11-2011, 09:36 AM
  3. Mark the difference
    By zhshqzyc in forum Access
    Replies: 1
    Last Post: 01-28-2011, 08:49 AM
  4. Hyperlink hell
    By Avinit in forum Access
    Replies: 1
    Last Post: 12-12-2010, 08:29 PM
  5. Transferring text within quotation marks
    By Lynette in forum Access
    Replies: 6
    Last Post: 11-24-2010, 11:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums