0

In a brand new MS Access 2010 database, I linked to two tables from a SQLite database using an ODBC connection. I have the following union query:

SELECT Calibration_Header.Gage_ID FROM Calibration_Header
UNION SELECT CHArchive.Gage_ID FROM CHArchive;

If I execute this SQL against the same database using the sqlite3 command line application, it runs successfully and returns the proper data. When I run the query in the MS Access 2010 database, I get the following error message:

ODBC--call failed.

near "(": syntax error (1) (#1)

Other union queries against different tables get the same error message when run in MS Access. When run in the sqlite3 command line, they run successfully and return the proper data.

3
  • Thanks for the information. The front end database that this is targeted for will be able to use Access or SQLite as the back end database, so a pass-through query wouldn't be ideal. Commented Dec 5, 2011 at 16:35
  • A union query is not a standard solution for a final application. Perhaps you could say a little more about what you wish to do and someone may be able to offer a lateral solution? Commented Dec 5, 2011 at 16:38
  • Records can be archived, which takes them out of the regular tables and puts them in archive tables. Several combo boxes in forms need to be able to see the Gage ID for all records, archived and not. The union query is to drive those combo boxes. I could create temp tables that get filled each time the form opens, but that is overhead I was hoping to avoid. Commented Dec 6, 2011 at 18:11

2 Answers 2

0

I suspect that a UNION SELECT is not in the standard Access vernacular. You can try implementing ANSI-92 in Access 2010 and then running your query as code, as described by Albert Kallal at http://www.utteraccess.com/forum/Create-View-Access-t1924479.html&p=1924500#entry1924500. I used these instructions to successfully create an Access "view".

Sign up to request clarification or add additional context in comments.

1 Comment

UNION SELECT is standard Access. No problems there. I think the problem was that Access was having problems using Union while dealing with the external link to the source tables. In that case, the OP's idea of 'archive tables' (or staging tables as I'd call them) would work better.
0

I realise that this is a very old thread, but I have just had this problem and found a pretty simple solution, so thought it worth sharing in case anyone else has the problem. Although Access seems unable to run a UNION query on two linked tables, if you create a pass-through query and put the SQL for the UNION in there, it works ok. Presumably the SQL is then executed by SQLite and the results returned as a single resultset, rather than Access itself trying to apply the UNION to two separate resultsets.

I am unable to test in earlier versions, but it works in Access 2016.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.