Results 1 to 13 of 13
  1. #1
    mcucino is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Jul 2017
    Location
    Providence, RI
    Posts
    74

    Insert multiple lines of values by enumerating with a "#"?

    I have never seen SQL like this and the ODBC software I'm using says it should work. The destination table has a field called "JournalLine_LineAmount" and supposedly Access can parse this SQL into multiple lines of data, however I get a syntax error every time I try. I mostly want to know if anyone has ever seen this notation before and if so, do you know how to get past the syntax error?

    INSERT INTO ManualJournals (Narration, JournalLine_LineAmount#1, JournalLine_AccountCode#1, JournalLine_LineAmount#2, JournalLine_AccountCode#2, JournalLine_LineAmount#3, JournalLine_AccountCode#3, JournalLine_LineAmount#4, JournalLine_AccountCode#4, JournalLine_LineAmount#5, JournalLine_AccountCode#5) VALUES ('Accrued expenses', ‘30’, '200', '-20', '310','10','425','-10','429','-10','310');

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    That would save one record, not multiple records. There would have to be fields with those names (a non-normalized structure). Where did you read this would create multiple lines of data?

    If fields are number type, do not use apostrophe delimiters.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,933
    # is not a character to be used in table and field names, try putting square brackets around the name, it sometimes helps. e.g [JournalLine_LineAmount#1]

    supposedly Access can parse this SQL into multiple lines of data
    nope - no sql will create multiple lines in this way

    the ODBC software I'm using says it should work
    can you provide a link that explains this

    you say you are using ODBC software - please clarify what you mean. ODBC usually means Open Data Base Connectivity and is not software but a means to connect to a database

  4. #4
    mcucino is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Jul 2017
    Location
    Providence, RI
    Posts
    74
    I agree it sounds crazy, but here are the docs, straight from the ODBC developer with data structures and examples:

    http://cdn.cdata.com/help/DXC/odbc/p...aljournals.htm

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    What are CData and Xero?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    mcucino is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Jul 2017
    Location
    Providence, RI
    Posts
    74
    Cdata is the software company that makes an ODBC to Xero (which is an accounting software)

  7. #7
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    @mcucino
    Are you using or trying to use Xero with MS Access?
    Have you contacted Xero? Or CData for working examples/tutorials?

    I am not familiar/never heard of Xero.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Still not clear what you mean by ODBC software. ODBC is a method of connecting to database. Access connects to Oracle or SQLServer via ODBC. Same for other frontend apps like VB.net.

    The SQL engine in Access cannot process that statement in the manner described.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,933
    I've heard of Xero - it's the newish kid on the block for online accounting software. One of my clients uses it although I have not had any involvement myself. However the implication from the documentation is that the data is held on your servers, not online, so leaves me a bit confused.

    @mcucino - your link makes things clearer. the requirement is to use an ODBC API which utilises a SQL style statement as a means of updating Xero Manual Journal tables, not Access ones. And from the documentation, the sql you quote only applies to manual journals (being one type of transaction in the application) - in other systems the data is usually supplied (more traditionally) in rows from a .csv or .txt file and passed through an import process. Reading through the documentation, what does surprise me is that when linked to a Xero table, you can make changes from Access - 'changes made to it will be reflected back to the underlying table in Xero.' I would think that could be really dangerous but I don't know enough about Xero to be sure.

    Your error is the values (30, -20,etc), they are numeric and should not be surrounded by single quotes - check the documentation you provided and you will see. You may also need to include the decimals (ie. 30.00), depends how fussy Xero is.

  10. #10
    mcucino is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Jul 2017
    Location
    Providence, RI
    Posts
    74
    ODBC is a method of connecting to a database, correct. There are various drivers that can allow users to use ODBC when it's not natively available in the software in question. In this case, that software is Xero. In other cases, it may be quickbooks. You cannot connect the data in Access directly to quickbooks without an ODBC driver such as QODBC. I hope that makes sense. If not, I encourage you to check out Cdata's website, https://www.cdata.com/odbc/ because they offer over 100 different drivers that allow you to use sources that otherwise would not be compatible using ODBC.



    Quote Originally Posted by June7 View Post
    Still not clear what you mean by ODBC software. ODBC is a method of connecting to database. Access connects to Oracle or SQLServer via ODBC. Same for other frontend apps like VB.net.

    The SQL engine in Access cannot process that statement in the manner described.

  11. #11
    mcucino is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Jul 2017
    Location
    Providence, RI
    Posts
    74
    Thanks, I tried it both ways (with and without quotes) because the email from Cdata support instructed me to use the quotes. It still doesn't help. I will try it with decimal places, but I think the issue is that it's not recognizing the enumerated field names. I put them in brackets as suggested above and it got past the initial syntax error, but now the error message states "unknown field name". It's very frustrating, considering how helpful their support team has been. They showed me step by step screenshots of using this exact query in Access and the output it produces, so I am at a loss for how to proceed.

    Click image for larger version. 

Name:	Capture.JPG 
Views:	10 
Size:	111.5 KB 
ID:	35450

    Quote Originally Posted by Ajax View Post
    I've heard of Xero - it's the newish kid on the block for online accounting software. One of my clients uses it although I have not had any involvement myself. However the implication from the documentation is that the data is held on your servers, not online, so leaves me a bit confused.

    @mcucino - your link makes things clearer. the requirement is to use an ODBC API which utilises a SQL style statement as a means of updating Xero Manual Journal tables, not Access ones. And from the documentation, the sql you quote only applies to manual journals (being one type of transaction in the application) - in other systems the data is usually supplied (more traditionally) in rows from a .csv or .txt file and passed through an import process. Reading through the documentation, what does surprise me is that when linked to a Xero table, you can make changes from Access - 'changes made to it will be reflected back to the underlying table in Xero.' I would think that could be really dangerous but I don't know enough about Xero to be sure.

    Your error is the values (30, -20,etc), they are numeric and should not be surrounded by single quotes - check the documentation you provided and you will see. You may also need to include the decimals (ie. 30.00), depends how fussy Xero is.

  12. #12
    mcucino is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Jul 2017
    Location
    Providence, RI
    Posts
    74
    EUREKA! I knew posting to the forum would help. Even if it's just because I had to reread the support email once I screenshotted it. There is one subtle difference in his query. I was attempting to operate on a linked table directly in Access whereas he was using a passthrough query. I'm not sure how dumb of a mistake that was on my part - but it finally works!

  13. #13
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,933
    he was using a passthrough query
    that was going to be my next suggestion. - and your query still has quotes around some of the numbers

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

Similar Threads

  1. Replies: 3
    Last Post: 09-21-2017, 05:40 AM
  2. Query for multiple values to display "All"
    By vicsaccess in forum Queries
    Replies: 3
    Last Post: 06-25-2016, 08:54 PM
  3. Replies: 2
    Last Post: 04-12-2016, 12:58 PM
  4. Replies: 9
    Last Post: 02-02-2016, 06:27 AM
  5. Replies: 1
    Last Post: 09-07-2015, 08:00 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