Duane said:
MSQuery allows you to set criteria. This isn't done in Access. The
criteria
can reference a cell in the worksheet.
Did you test e.g. using 'Employee Sales by Country' in the Access/Jet
Northwind test database?
In my experience, 'Criteria' will not help you run a Access/Jet
Parameter Query (big Q) from MSQuery in Excel.
Here's what I tried
1. Open a workbook using the Excel app.
2. Choose: Data, Import External Data, New Database Query.
3. Choose a connection to Northwind (I'm using a DSN).
4. MSQuery starts with its 'Add Tables' dialog displayed.
5. Hit the Options and ensure 'Views' is checked then hit OK.
6. Back in the 'Add Tables' dialog, select the Parameter Query
'Employee Sales by Country', hit 'Add' then 'Close'.
7. In the 'Tables' pane of the main MSQuery window, choose one of the
columns (or * for all columns) by double clicking.
8. See the error message, 'Too few parameters. Expected 2'.
The problem here is that 'Employee Sales by Country' is a PROCEDURE,
rather than a VIEW. So rather than use SELECT, which is all MSQuery
'knows', you must EXECUTE the proc
9. From the MSQuery menu, choose: View, SQL.
10. Type (or paste) the following SQL (Jet syntax)
EXECUTE [Employee Sales by Country] #1994-08-01#, #1994-08-15#
11. Hit OK when warned 'SQL Query can't be represented graphically'.
12. The resultset of the proc call is shown in the main MSQuery window.
The 'can't be represented graphically' is significant because when you
see this you have confirmation that 'Criteria' support has been lost.
This means that to change the parameters to reference a worksheet,
UserForm, etc you must use code.