Thread: SQL query
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
sebastienm sebastienm is offline
external usenet poster
 
Posts: 694
Default SQL query


To make it simpler, you could add parameters to your query. This requires
you to work in the MS Query:
- right - click the returned data and choose Edit Query from the popup menu.
- at the last step of the Wizard ("Query Wizard - Finsh"), choose 'View Data
or Edit Query in Microsoft Query' , click ok (or finish). MS Query opens.
- In MS Query:
- make sure the Criteria pan is visible (menu View Criteria).
- there, as Criteria Field, enter the date field name , say MyDate, and
as Value enter: Between [param1] And [param2]
This automatically crates 2 paramaters
- In menu View Parameters, select each of them, click Edit and change
their datatype to Datetime.
- run the query to test (chcek the sql too)
- return the data to Excel: menu File Return Data to MS Excel
- Back to Excel. Now we want to specify the parameters.
- right-click the query data and choose Parameters from the popup menu
(notice that the Paramaters submenu is enabled now)
- Choose from the 3 options proposed to you: prompt for value at each
refresh/run of the query, use a constant value, or get the value from a
specific cell (with or without auto-refresh when the value changes).

You could set 2 cells to contain the date parameters and have the query
auto-refresh when it is modified. Using Data Validation, you could also have
these 2 cells have a dropdown allowing the user to select some dates from a
set of values.

I hope this helps,
--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"Darron Ross" wrote:

Thanks for you help,

I went through your insructions and I'm at Query Wizard Data Filter window.
It allows me to pick the datetime field to filter with options to pick
greater than or less than; then a pull down selection lets me select the
date. Below that I have a "and" button and a "or" button to select the next
argument. From this I'm having trouble getting it to pick two dates and
return the date between those dates.

again thanks for your help.