Results 1 to 5 of 5
  1. #1
    chalupabatman is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Aug 2016
    Posts
    114

    VBA Syntax Error

    I am getting an error on this line, but not sure what is causing it. I have this all as one line (no breaks like shown below) in the VBE but i added the breaks for cleanliness of view in the window

    How do I alter so this does no longer produce a compile error?



    Code:
    DoCmd.RunSQL ("SELECT [HKI].[SalesID], 
    			  ConcatRelated("Part","[HKI]","SalesID = '" & [SalesID] & "'") AS Part,
    			  ConcatRelated("Amount","[HKI]","SalesID = '" & [SalesID] & "'") AS Amount 
    			  INTO [Export] 
    			  FROM [HKI]")

  2. #2
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Would help to know the error??


    Is [SalesID] text or numeric??

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    The double quotes of the concat function terminate the quotes started at the SELECT statement. Try this shot-in-the-dark:

    Code:
    DoCmd.RunSQL ("SELECT [HKI].[SalesID], 
                  ConcatRelated('Part','[HKI]','SalesID = ' & Chr(34)  & [SalesID] & Chr(34) & ') AS Part
                  INTO [Export] 
                  FROM [HKI]")
    Then add the second one with similar quoting if that works. If it doesn't work, It's because I'm late for dinner and feeling faint.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    chalupabatman is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Aug 2016
    Posts
    114
    @pbaldy - that got it, thank you!

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Happy to help!
    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: 01-04-2016, 09:40 AM
  2. Replies: 11
    Last Post: 05-01-2014, 11:56 AM
  3. Replies: 3
    Last Post: 01-23-2014, 07:49 AM
  4. Replies: 6
    Last Post: 05-30-2012, 12:32 PM
  5. Incomplete Syntax Clause (syntax error)
    By ajetrumpet in forum Programming
    Replies: 4
    Last Post: 09-11-2010, 10:47 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