Tony:
You are making this MUCH more complex than is should be. Here's how to do
it.
Let say you have a field with the Date and another with the time,
(alternately a full date time field assuming that it is long date time
format rather than a short date/time which will result in putting all the
dates in with a 12:00:00 for the time.)
Notwithstanding that you can parse a time field using the DatePart function
to pull the hour the reading occurred on a 24 hour basis. I.e.
datepart("h",#23:15:00#) = 23
Then create a simple little table in your db that just has one column called
HOUR and fill it with 24 rows with 1 to 24 as values for the Hour field.
Then, add your data table to a query adding the date, datepart of time and
the reading; that's query one. Create a second query which includes just
the date field from your data table (filtered as appropriate for the date
range you want), and the 24 hour table, drag the date and the hour field on
to the query grid, but do NOT join the tables. You should get as a result
from this query something like this:
5/2/2003 1
5/2/2003 2
5/2/2003 3
etc.
One row for each date and the 24 hours.
Then create a third query which incorporates the first data query and to
that query add your date/hours query. Create a left outer join between the
date/hour query and the data query joining on date and hour including all
the rows form the date/hour query and only those rows from the data query
that have matching rows. In the measure field, alias that with a little
IIF function (don't use NZ it tends to return strings rather than numbers)
to make sure that if you have a null value for any hour's reading you return
a zero as in:
Read: IIF(IsNull([Reading]),0, [Reading])
The result from this thid query might look like this:
5/2/2003 1 3.65
5/2/2003 2 0
5/2/2003 3 5.63
etc.
So now you have all your data drawn by queries, which are substantially
faster than VBA loops.
In your report then, simply create groups on the date and in the group
footer, if you need a calc such as a sum, use the report to do that
calculation; if you need calcs for each detail line use the On print event
to do your calc.
--
Steve Arbaugh
ACG Soft
http://ourworld.compuserve.com/homepages/attac-cg
Tony Piperato said:
Yes, but HOW do I do it? Let me expand on my needs:
1) I have a VERY complicated calculation involving a table.
2) I will run through a for/next loop to represent a 24 hour period
(for
x
= 1 to 24) and NO I cannot use an outer join with a table that has 24 rows.
3) I need to print the 24 hours down the page of the report along with the
results from my calculation, so the result would look like:
Hour Reading
1 5.76
2 0
3 3.45
etc..
4) I can have more than one day's worth of readings and so will need to
group on date which IS in the table data.
There you are. All I want to know is first; How do I attach the hour data
to a textbox if it is coming from a for/next loop and second; how do I
attach the "reading" data (which is a calculation remember) to the "reading"
textbox on the report.
Hope this clears things up and thanks again for all your help.
Tony
pull
all in
the
as
a to got detail
area such
as Also,