Re: Date based query problem
- From: "John Spencer" <spencer@xxxxxxxxx>
- Date: Thu, 4 Oct 2007 15:48:13 -0400
SELECT Sum(CardsSold) as TotalSold
, Sum(CardsPurchased) as TotalBought
, (SELECT Sum(CardsPurchased)
FROM Inventory
WHERE Inventory.ActionDate < [Beginning Date]) as PriorPurchases
FROM Inventory
WHERE Inventory.ActionDate Between [Beginning Date] and [Ending Date]
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
"Lissa" <Lissa@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:4D101497-BB1D-4EF3-92B3-336A617EBB25@xxxxxxxxxxxxxxxx
I have an inventory database (in Access 2007) that calculates the Beginning
Inventory, # Cards Sold, # Cards Purchased, and Ending Inventory. I have a
query that pulls the # Cards Sold, # Cards Purchased, and calculates the
Ending Inventory based on the date parameters given to the report ("Enter
Beginning Date" and "Enter Ending Date"), but I need to pull the Beginning
Inventory information based on all data prior to the "Beginning Date" of
the
report.
For instance... the date parameters are 5/1/07 (Beginning Date) and
5/31/07
(Ending Date), so the Beginning Inventory should pull all # Cards Sold and
#
Cards Purchased from the beginning of time through 4/30/07 (one day prior
to
the Beginning Date parameter). I can't seem to make this work no matter
what
I do. I have created 2 queries -- one that pulls and calculates all the
information for the report parameters and another that calculates the
Beginning Inventory seperately. If I combine the information on the
queries
the totals are all wrong and I can't figure out how to get the Beginning
Inventory field on the report when it's not from the same data source as
the
data query.
Am I going about this the wrong way? Is there an easier way to do all
this?
Any help would be greatly appreciated!! Thanks Lissa
.
- Follow-Ups:
- Re: Date based query problem
- From: Lissa
- Re: Date based query problem
- References:
- Date based query problem
- From: Lissa
- Date based query problem
- Prev by Date: Re: Problem formatting data in text fields in Access Report
- Next by Date: Re: Report help
- Previous by thread: Date based query problem
- Next by thread: Re: Date based query problem
- Index(es):
Relevant Pages
|