On Thu, 21 Apr 2011 11:36:33 -0700 (PDT), carl <(E-Mail Removed)> wrote:
> I use this query...
>
>TRANSFORM Sum(Nz([PC Vol]/2,0)+Nz([BD Vol]/2,0)+Nz([MM Vol]/2,0)) AS
>Expr1
>SELECT OCC_Data.underlying, Sum([PC Vol]/2)+Sum([BD Vol]/2)+Sum([MM
>Vol]/2) AS OCC_Vol
>FROM OCC_Data
>WHERE (((OCC_Data.date)=[EnterDate yyyymmdd]) AND ((OCC_Data.Product)
>In ('OSTK','OIND'))) and OCC_Data.underlying Not In
>('VIX','SPX','OEX','DJX')
>GROUP BY OCC_Data.underlying
>PIVOT OCC_Data.exchange In ("A","B","C","I","P","Q","W","X","Z");
>
>
>Which prompts me for a date. Is there a way to change the query so
>when the user gets prompted to enter a date, that the can enter
>20110410 for April 19 2011 OR enter 201104 and get all records for
>April 2011.
>
>
>Thanks in advance.
>
Assuming that the date field is of Text datatype (as appears to be the case)
then yes:
TRANSFORM Sum(Nz([PC Vol]/2,0)+Nz([BD Vol]/2,0)+Nz([MM Vol]/2,0)) AS
Expr1
SELECT OCC_Data.underlying, Sum([PC Vol]/2)+Sum([BD Vol]/2)+Sum([MM
Vol]/2) AS OCC_Vol
FROM OCC_Data
WHERE (((OCC_Data.date) LIKE [EnterDate yyyymmdd or yyyymm] & "*") AND
((OCC_Data.Product)
In ('OSTK','OIND'))) and OCC_Data.underlying Not In
('VIX','SPX','OEX','DJX')
GROUP BY OCC_Data.underlying
PIVOT OCC_Data.exchange In ("A","B","C","I","P","Q","W","X","Z");
This might be a bit awkward: if the user enters 2011 they'll get all records
for that year, if they enter 20 they'll get all records from the 21st century,
if they enter a blank they'll get all records.
I'd probably use a Date/Time field for the date field (and would *NOT* use the
reserved word Date as a fieldname) and a Form to collect criteria, rather than
a prompt.
--
John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/For...-US/accessdev/
http://social.answers.microsoft.com/.../en-US/addbuz/
and see also
http://www.utteraccess.com