Hi all,
I write lots of reports in Excel that use MSQuery to get data.
Whenever I need to write some SQL that gets data from multiple sources (I need to mix tables from an Access database with those from an ODBC source) I'm forced to use Access, because I can't seem to get MSQuery to access more than one data source at a time. Is there a way around this?
To get around this I've been using Access to construct the query, and then using MSQuery to pull the data from the saved Access query. This works really well, except when I need to filter out results based on data in the Excel workbook.
For example:
In Access I have a query with this SQL:
But in Excel, I just want data for one date, so in MSQuery, the SQL looks like
And Excel prompts for the DateParam when the query is returned. The big problem is that ALL of the data for all dates is returned to MSQuery when then filters it out, resulting in a long time to return a small amount of data. How can I get around this?
Obviously in this example, it would be simpler to retrieve those tables separately into Excel and merge them there - but I need a proper solution because I have heaps of very complex SQL queries like this.
Many thanks!
I write lots of reports in Excel that use MSQuery to get data.
Whenever I need to write some SQL that gets data from multiple sources (I need to mix tables from an Access database with those from an ODBC source) I'm forced to use Access, because I can't seem to get MSQuery to access more than one data source at a time. Is there a way around this?
To get around this I've been using Access to construct the query, and then using MSQuery to pull the data from the saved Access query. This works really well, except when I need to filter out results based on data in the Excel workbook.
For example:
In Access I have a query with this SQL:
Code:
SELECT CodeField, DateField FROM LocalTable
UNION ALL
SELECT CodeField, DateField FROM ODBCTable
Code:
SELECT CodeField, DateField
FROM SavedAccessQuery
WHERE DateField = [DateParam]
Obviously in this example, it would be simpler to retrieve those tables separately into Excel and merge them there - but I need a proper solution because I have heaps of very complex SQL queries like this.
Many thanks!