Results 1 to 4 of 4
  1. #1
    Juan4412 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Dec 2010
    Posts
    209

    VBA Query Syntax


    I am using Debug.Print to check my syntax and after all is said and done this is the output from the Print statement. I get an error of Invalid Syntax when I execute this - but what element is invalid?

    Code:
    INSERT INTO VBAInsert ( CAC, Description, SS, MQ, P, AD, CPC ) SELECT CAC, [ItemCode] & ' ' & [Description] AS FullDescription, RED As SS,0 As MQ,0 As P,4/10/2017 As AD,TEST As CPC FROM TempHold;

  2. #2
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Text fields have quotes around them (RED/TEST table field or a text?), dates have #'s around them - #4/1/2017#. I would stay away from Access reserved words - if TEST is a field name.

  3. #3
    Juan4412 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Dec 2010
    Posts
    209
    They are text values being input into fields. So I would need to encompass with "" - and good call about the dates!

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    You can encompass text values in either " marks or ' marks. Either one works, just make sure there's no chance of your data entry including a ' mark if you use ' encapsulation.

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

Similar Threads

  1. Query Syntax
    By broodmdh in forum Access
    Replies: 1
    Last Post: 10-29-2015, 12:29 PM
  2. query syntax,
    By fluppe in forum Access
    Replies: 4
    Last Post: 07-25-2014, 02:42 AM
  3. Query Syntax
    By dolovenature in forum Access
    Replies: 1
    Last Post: 08-29-2012, 06:54 PM
  4. Incomplete Syntax Clause (syntax error)
    By ajetrumpet in forum Programming
    Replies: 4
    Last Post: 09-11-2010, 10:47 AM
  5. Sql Syntax Query
    By Matthieu in forum Queries
    Replies: 4
    Last Post: 12-30-2009, 09:41 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