Day Calculation in Report

F

Frustrated

I have a report that is grouping all contracts that are occuring for each day
of the week (totalled in the Day Footer) This is all calculating correctly
but in the Report footer, I have totals and calculations based on the Day
footer info. The only problem I have is the Day calculation. Some of the
Report Footer info is based on the number of days in the week ie 5 or 6, but
the day calculation field is showing all the number of records in the Day
footer ie 31. I want to show only the number of days and not the number of
records - can anyone help please.
 
J

James A. Fortune

Frustrated said:
I have a report that is grouping all contracts that are occuring for each day
of the week (totalled in the Day Footer) This is all calculating correctly
but in the Report footer, I have totals and calculations based on the Day
footer info. The only problem I have is the Day calculation. Some of the
Report Footer info is based on the number of days in the week ie 5 or 6, but
the day calculation field is showing all the number of records in the Day
footer ie 31. I want to show only the number of days and not the number of
records - can anyone help please.

Here is the technique I use:

http://groups.google.com/group/comp.databases.ms-access/msg/bd41f6f15fc5977f

By sending SQL to a public function from a textbox's RecordSource you
can bring in information that is totally unrelated to the RecordSource
of the report or that is related to one of its groups by using the
contents of a textbox(es) in the header(s) as part of the SQL string's
criteria. For simple criteria a DLookup function can also be used in
the RecordSource. If you want, you can calculate the percentage a group
sum is of the sum of the group that contains it. You can even compare
data that is included in the Report's RecordSource with data in the same
table that is not included in the Report's RecordSource; it gives you
total freedom. It might be possible to use SQL directly in a report's
RecordSource but that doesn't work in Access 97 which I must use for now
in support of my environment containing that version and all later
versions of Access. Others have come up with clever solutions by using
the IIF function to filter the Report's RecordSource data differently.
That will work for many problems but that method has more limitations.

James A. Fortune
(e-mail address removed)
 
F

Frustrated

Thank you James but I am fairly new to Access and I don't understand your
comment. To further explain my problem, my report does not show any details
but I have subtotalled in the Day footer which gives me all contracts carried
out on that day. Each day is showing with totals for the day.

In the Report footer, all subtotals are now totalling and I need to have the
contracts averaged per hour per day but the day field is showing 31 which is
actually the total number of contracts for the week. I want the day field to
show the number of days showing in my Day footer which is 6 - Monday to
Saturday.
 
J

James A. Fortune

Frustrated said:
Thank you James but I am fairly new to Access and I don't understand your
comment. To further explain my problem, my report does not show any details
but I have subtotalled in the Day footer which gives me all contracts carried
out on that day. Each day is showing with totals for the day.

In the Report footer, all subtotals are now totalling and I need to have the
contracts averaged per hour per day but the day field is showing 31 which is
actually the total number of contracts for the week. I want the day field to
show the number of days showing in my Day footer which is 6 - Monday to
Saturday.

I guess it would help me greatly to see a concrete example. Perhaps
show ten records with the table and field names. Then show your report
RecordSource SQL, the results your report produces and what fields
you're using for Sorting and Grouping (perhaps by Day only). Then show
what you want group totaled and where in addition to those results.
That way everyone will be better able to understand the problem you're
having. If you have a separate table that is used to contain hours
worked on a contract for a given day then you should show a sample
record/row including field names for that table also. Once we
understand your problem I am confident that someone here can help you
solve it.

James A. Fortune
(e-mail address removed)
 
F

Frustrated

Ok - The table "Yearly Grains Bookings" has multiple fields but the ones in
question are:

Field - Property

Week - number - long int
Week starting - medium date
Day - text
Time - time
Cont ID - number
Seq - Number

Day Lookup Table:
Day - Text
DayID - Autonumber

The database is set up with a week number and the week starting is a
Thursday. The data is placed in the table for the week. At a later stage,
someone will retrive the records for the week and then allocate that contract
to a day and a time for that week. The contract is then loaded etc.

The report is set up with a query and a parameter for the user to enter the
week number :

SELECT [Weekly Productivity Report].DayID, [Weekly Productivity
Report].Week, [Weekly Productivity Report].[Cont Id], [Weekly Productivity
Report].[Booking ID], [Weekly Productivity Report].[Week Starting], [Weekly
Productivity Report].Day, [Weekly Productivity Report].[St 1 Cancelled],
[Weekly Productivity Report].[Cancelled Other], [Weekly Productivity
Report].[No of Containers], [Weekly Productivity Report].[Completed
Containers], [Weekly Productivity Report].Tonnes, [no of
containers]-[completed containers] AS Variance, [Weekly Productivity
Report].[CBH Lost Time], Sum([T_Crew Downtime].Minutes) AS SumOfMinutes,
Sum([T_Crew Downtime].Numbers) AS SumOfNumbers, Sum([minutes]*[numbers]) AS
[Total Time], Sum([minutes]*[numbers]*0.65) AS Cost
FROM [T_Crew Downtime] RIGHT JOIN [Weekly Productivity Report] ON [T_Crew
Downtime].[Booking ID] = [Weekly Productivity Report].[Booking ID]
GROUP BY [Weekly Productivity Report].DayID, [Weekly Productivity
Report].Week, [Weekly Productivity Report].[Cont Id], [Weekly Productivity
Report].[Booking ID], [Weekly Productivity Report].[Week Starting], [Weekly
Productivity Report].Day, [Weekly Productivity Report].[St 1 Cancelled],
[Weekly Productivity Report].[Cancelled Other], [Weekly Productivity
Report].[No of Containers], [Weekly Productivity Report].[Completed
Containers], [Weekly Productivity Report].Tonnes, [no of
containers]-[completed containers], [Weekly Productivity Report].[CBH Lost
Time];

I have the grouping and sorting as -
St 1 Cancelled first with Group Properties - Yes to Group header and footer,
Each Value, 1 and whole group
DAYID - with the same group properties as above.

The DAYID is from a lookup table that has an autonumber as the primary key
and the days of the week (with the first day being Thurs which is the start
of the working week). I sort on the DayID so that the records are listed for
each day starting Thursday.

The DayID Header has the "Day" field
The DayID Footer has the following fields: "Day" is the control source.
The field next is the "Week Starting" field + "DAYID"-1. This gives me a
date for each day in the report based on the Week Starting listed in the
Report Header.
The DayID footer has all the containers etc as sum values.

I Have tried the "Day" field in the DAYID footer with the count equation. I
have tried having "Day" header and footer and "Week Starting" header and
footer but they always show 31 which are the number of contracts that are
processed in that week.
I have also tried using the "DayID" field to count but in every case it
also comes back to the 31.

My problem is that most weeks the crews will only be working 5 days but in
some instances they can be working 6 or 7. The report shows the correct days
worked but I need to be able to use the number of days worked in the week
against the calculations. I have even tried putting in an unbound control
and putting this in the footer to count - same conclusion.


I'm sorry but it's not possible to copy the report into this area.
 
J

James A. Fortune

Frustrated said:
Ok - The table "Yearly Grains Bookings" has multiple fields but the ones in
question are:

Field - Property

Week - number - long int
Week starting - medium date
Day - text
Time - time
Cont ID - number
Seq - Number

Day Lookup Table:
Day - Text
DayID - Autonumber

The database is set up with a week number and the week starting is a
Thursday. The data is placed in the table for the week. At a later stage,
someone will retrive the records for the week and then allocate that contract
to a day and a time for that week. The contract is then loaded etc.

The report is set up with a query and a parameter for the user to enter the
week number :

SELECT [Weekly Productivity Report].DayID, [Weekly Productivity
Report].Week, [Weekly Productivity Report].[Cont Id], [Weekly Productivity
Report].[Booking ID], [Weekly Productivity Report].[Week Starting], [Weekly
Productivity Report].Day, [Weekly Productivity Report].[St 1 Cancelled],
[Weekly Productivity Report].[Cancelled Other], [Weekly Productivity
Report].[No of Containers], [Weekly Productivity Report].[Completed
Containers], [Weekly Productivity Report].Tonnes, [no of
containers]-[completed containers] AS Variance, [Weekly Productivity
Report].[CBH Lost Time], Sum([T_Crew Downtime].Minutes) AS SumOfMinutes,
Sum([T_Crew Downtime].Numbers) AS SumOfNumbers, Sum([minutes]*[numbers]) AS
[Total Time], Sum([minutes]*[numbers]*0.65) AS Cost
FROM [T_Crew Downtime] RIGHT JOIN [Weekly Productivity Report] ON [T_Crew
Downtime].[Booking ID] = [Weekly Productivity Report].[Booking ID]
GROUP BY [Weekly Productivity Report].DayID, [Weekly Productivity
Report].Week, [Weekly Productivity Report].[Cont Id], [Weekly Productivity
Report].[Booking ID], [Weekly Productivity Report].[Week Starting], [Weekly
Productivity Report].Day, [Weekly Productivity Report].[St 1 Cancelled],
[Weekly Productivity Report].[Cancelled Other], [Weekly Productivity
Report].[No of Containers], [Weekly Productivity Report].[Completed
Containers], [Weekly Productivity Report].Tonnes, [no of
containers]-[completed containers], [Weekly Productivity Report].[CBH Lost
Time];

I have the grouping and sorting as -
St 1 Cancelled first with Group Properties - Yes to Group header and footer,
Each Value, 1 and whole group
DAYID - with the same group properties as above.

The DAYID is from a lookup table that has an autonumber as the primary key
and the days of the week (with the first day being Thurs which is the start
of the working week). I sort on the DayID so that the records are listed for
each day starting Thursday.

The DayID Header has the "Day" field
The DayID Footer has the following fields: "Day" is the control source.
The field next is the "Week Starting" field + "DAYID"-1. This gives me a
date for each day in the report based on the Week Starting listed in the
Report Header.
The DayID footer has all the containers etc as sum values.

I Have tried the "Day" field in the DAYID footer with the count equation. I
have tried having "Day" header and footer and "Week Starting" header and
footer but they always show 31 which are the number of contracts that are
processed in that week.
I have also tried using the "DayID" field to count but in every case it
also comes back to the 31.

My problem is that most weeks the crews will only be working 5 days but in
some instances they can be working 6 or 7. The report shows the correct days
worked but I need to be able to use the number of days worked in the week
against the calculations. I have even tried putting in an unbound control
and putting this in the footer to count - same conclusion.


I'm sorry but it's not possible to copy the report into this area.

Thanks for the information. I won't be able to look at it until Monday.
In the meantime anyone who would like to step in and tackle this one
is welcome. Note that Week, Day and Time aren't very good field names
to use because they are potentially confusing to Access. Also, even
showing a single record from "Yearly Grains Bookings" and "Day Lookup"
would help quite a bit so that no one wastes time guessing at what you
have. A sample record from the query could also help you receive an
answer more quickly. I often create a similar table and create a
similar query so that I can experiment and see what is going on. The
sample record/row from the query helps me make sure that we are looking
at the same problem. You're very familiar with your data. We in this
NG are not. An example of what you want to get helps us verify that our
solution fits your problem. The field [Week] can be derived from [Week
starting] so it might be possible to delete one or more fields. Also,
by seeing an example it may be possible to reorganize your table
structure in a way that makes getting the information you want into a
query more easily. It's likely that the way you have chosen to manage
your data's lifetime is not the best. Is the data in the table deleted
after it is retrieved so that it can be used the following year? In
fact, much of your data's organization seems nonstandard and looks like
it needs some TLC in order to do what you want efficiently. I would
guess that you don't need the "Day Lookup" table at all. It's likely
that an entry date (including the year) in the "Yearly Grains Bookings"
table is all you need to do everything you want to do in your report.

James A. Fortune
(e-mail address removed)
 
F

Frustrated

It's alright James. I used a TxtGroupCount field in the Day footer with the
control source set to =1 and in the Report Footer another field with the
control Source of =[TxtGroupCount] which worked perfectly.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top