Results 1 to 2 of 2
  1. #1
    darwish is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2014
    Posts
    26

    Embedding Quotations in a String

    Dears

    In my VBA Code I have a string as below

    scriptstatementJT = "Insert into JOBTASK(JPNUM, JPTASK, DESCRIPTION) Values('" & jpnum2 & "','" & task & "','" & Description& "')";

    I have a DataBase Table Called JTQUERIES i want to insert data to it

    strSQL = "INSERT INTO JTQUERIES (JOBPLAN,JPTASK,JTQUERY) VALUES ('" & jpnum2 & "','" & task & "', """ & [scriptstatementJT] & """ ); "


    Set cn = CurrentProject.Connection
    cn.Execute strSQL

    the problem is that i am having a syntax error when every time the Description Field is having a Double Quotations (") in its value. ex: Description = "Hello World How "Are You"";



    How can I solve this Problem?

    Thank you

  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    use the replace function to double them up and they will disappear e.g.

    ......task & "','" & replace(Description,""","""") & "')";

    or for single quotes

    ......task & "','" & replace(Description,"'","''") & "')";

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

Similar Threads

  1. Quotations Hit Rate
    By PaulMo in forum Reports
    Replies: 11
    Last Post: 08-03-2015, 12:44 PM
  2. Replies: 7
    Last Post: 11-27-2013, 03:14 PM
  3. Forms Printing Quotations?
    By lbtaylor1984 in forum Forms
    Replies: 8
    Last Post: 10-31-2013, 09:06 AM
  4. Help with quotations in DLookup
    By kenton.l.sparks@gmail.com in forum Access
    Replies: 1
    Last Post: 10-15-2012, 12:37 AM
  5. Quotations Database
    By Kari-z in forum Database Design
    Replies: 2
    Last Post: 01-26-2011, 09:03 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