Results 1 to 4 of 4
  1. #1
    broecher is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Posts
    38

    sql variable with apostrophes

    I am having a problem with the variable lastVic which can contains apostrophes.


    The error appears when from the update statement.

    Code:
     
            lastVic = DMax("LocationDescription", "Captures", "CatID = " & Me.CatID & " AND CaptureDate = #" & lastVicDate & "#")
            CurrentDb.Execute "UPDATE Cats SET LastVicinity = '" & lastVic & "' WHERE CatID = " & Me.CatID
    I have read that I need to use double quotes but I don't understand where they quotes go exactly.



    Thanks!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Try


    "UPDATE Cats SET LastVicinity = " & Chr(34) & lastVic & Chr(34) & " WHERE...
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    broecher is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Posts
    38
    that worked, and is easier for me to follow than a series of triple-double quotes. Thanks

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    No problem. This has a lot of info on the subject:

    http://www.baldyweb.com/BuildSQL.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 2
    Last Post: 04-17-2013, 04:59 AM
  2. Replies: 4
    Last Post: 09-05-2011, 11:10 PM
  3. Replies: 0
    Last Post: 08-10-2011, 11:59 AM
  4. Replies: 4
    Last Post: 08-05-2010, 01:26 PM
  5. Refering to variable form names inside a variable
    By redpetfran in forum Programming
    Replies: 2
    Last Post: 05-21-2010, 01:39 PM

Tags for this Thread

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