Results 1 to 4 of 4
  1. #1
    jo15765's Avatar
    jo15765 is offline Expert
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    670

    DoCmd RunSQL Statement With A Field Name that Holds ()

    I am getting an error of Compile error: Expected: list seperator or ) when I attempt to run the below syntax in my VBA.



    Code:
    DoCmd.RunSQL ("Select [testtable].[UnitID], [testtable].[User ID (Where identified)] FROM [testtable]")
    How in access 2013 vba can you accomodate for when a field contains open paren and close paren?

  2. #2
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    lose brackets at beginning and end.

    Code:
    DoCmd.RunSQL "Select [testtable].[UnitID], [testtable].[User ID (Where identified)] FROM [testtable]"

  3. #3
    jo15765's Avatar
    jo15765 is offline Expert
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    670
    Hah - thank you.

  4. #4
    jwhite is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2012
    Location
    North Carolina
    Posts
    349
    Do you really have a field named "User ID (Where identified)"? If so, I would strongly recommend that you change field names like this to NOT include symbols, spaces, or any other non-standard ASCII characters so that maintenance on your DB will be much easier in the future. Acceptable are A-Z, a-z, and Underscore (_).

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

Similar Threads

  1. Replies: 2
    Last Post: 09-22-2016, 05:09 AM
  2. Replies: 3
    Last Post: 01-27-2015, 12:25 PM
  3. Replies: 6
    Last Post: 02-24-2014, 09:26 AM
  4. Compile Error: Syntax Error in DoCmd.RunSQL Statement
    By Evilferret in forum Programming
    Replies: 1
    Last Post: 08-27-2012, 12:32 PM
  5. problem with my DoCmd.RunSQL statement
    By cgclower in forum Access
    Replies: 1
    Last Post: 07-24-2011, 06:12 PM

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