473,803 Members | 3,022 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calculate totals for period of time

I'm hoping someone can guide me on solving this vexing problem I have
with a database I built to track a projects. I'm using MS Access 2003
and here are the basics: the database is designed to track companies
that are supporting projects and the number of personnel in each
company that supports each project. I'm stuck when I want to sum the
total number of personnel supporting the project over a period of time.
For example:
Company A provides 10 people between 1 Aug 06 and 10 Aug 06
Company A provides 15 people between 11 Aug 06 and 20 Aug 06
Company B provides 12 people between 5 Aug 06 and 12 Aug 06
Company C provides 22 people between 9 Aug 06 and 16 Aug 06
Company C provides 28 people between 17 Aug 06 and 28 Aug 06

Report would show each day between a queried start date and end date
(not just dates where data was input). Using the example above I would
have something like the following:
1 Aug 10
2 Aug 10
3 Aug 10
4 Aug 10
5 Aug 22
6 Aug 22
7 Aug 22
8 Aug 22
9 Aug 44
Etc.
Where query start date would be 1 Aug and end date would be whatever
you pick.

My report should show total number of personnel working on the project
each day. I'm not taking into account holidays or weekends.

Database structure looks like this:
Tables
TblCompanies
CompanyID
CompanyLocation
Etc.

TblProjects
ProjectID
Company ID
ProjectType
ProjectLocation

TblPersonnelDat es
PersonnelDateID
ProjectID
PersonnelStartD ate
PersonnelEndDat e
PersonnelNumber

Data for the number of personnel for each company is updated any time
there is a change to that number (not necessarily on a daily basis).
>From the sums that I pull I will need to convert this to a graph, but
right now I'm just struggling to get the sums to work right. Any help
is GREATLY appreciated since I've been working on this for a few days
and have made no progress.

Sep 14 '06 #1
4 6702
I think you need to create the daily data.

Maybe write a select query to get the company name, the project name, the
start date, the end date and number of people.

Then walk that recordset with something like.

While not rs1.endEOF
For x = startdate to endate
rs2.append
Assign company, project etc to the fields of the new table
x = x +1
Loop
rs1.movenext
Loop

That would leave you with a table with all your data recorded by individual
calendar days.
In the process you could screen out weekends etc as you like.

By the way I assume their is some companyID in theTblPersonnel Dates? Else
how do you associate the hours to a company or is each project exclusive to
one company?

"Mayhem05" <EJ********@gma il.comwrote in message
news:11******** *************@m 73g2000cwd.goog legroups.com...
I'm hoping someone can guide me on solving this vexing problem I have
with a database I built to track a projects. I'm using MS Access 2003
and here are the basics: the database is designed to track companies
that are supporting projects and the number of personnel in each
company that supports each project. I'm stuck when I want to sum the
total number of personnel supporting the project over a period of time.
For example:
Company A provides 10 people between 1 Aug 06 and 10 Aug 06
Company A provides 15 people between 11 Aug 06 and 20 Aug 06
Company B provides 12 people between 5 Aug 06 and 12 Aug 06
Company C provides 22 people between 9 Aug 06 and 16 Aug 06
Company C provides 28 people between 17 Aug 06 and 28 Aug 06

Sep 15 '06 #2
Depending on what you want I may have given some less than optimum advice.
If you just want to know the number of staffdays provided you could get that
in a query (Still the problem of weekends,etc).

You would put a calculated field in the query something like:

Staffdays: = (datediff("d",[startdate],[enddate]) +1)* PersonnelNumber

So if there were 12 people for a period of 10 days that would return the
value of 120.

That assumes that the start and end dates are inclusive.
"Mayhem05" <EJ********@gma il.comwrote in message
news:11******** *************@m 73g2000cwd.goog legroups.com...
I'm hoping someone can guide me on solving this vexing problem I have
with a database I built to track a projects. I'm using MS Access 2003
and here are the basics: the database is designed to track companies
that are supporting projects and the number of personnel in each
company that supports each project. I'm stuck when I want to sum the
total number of personnel supporting the project over a period of time.
For example:
Company A provides 10 people between 1 Aug 06 and 10 Aug 06
Company A provides 15 people between 11 Aug 06 and 20 Aug 06
Company B provides 12 people between 5 Aug 06 and 12 Aug 06
Company C provides 22 people between 9 Aug 06 and 16 Aug 06
Company C provides 28 people between 17 Aug 06 and 28 Aug 06

Sep 15 '06 #3
Thank you KC Mass, that does get me started in the right direction.
I'm not concerned about weekends since I am considering them as a work
day for this database. The database is tracking support for emergencies
like natural disasters. I did plan on using a make-table query to
generate a 'temp' table for the data. My dillemma is in coming up with
a means to create this table from my initial query that will populate
records for each day to include the start/stop dates.

My initial query to determine what companies have personnel during said
periods of time is done and works properly. I now need to create the
afore mentioned create table query so I can ultimately create my
reports and charts. I'm just not much of a whiz with VBA.

I hope this further explanation helps clarify my situation.

Thanks,
Eric

Sep 19 '06 #4
Here is the coding I have so far. I think I'm missing some
declarations in. I have not tried running it since adding in the
coding after calling the query. Up through the query point the coding
worked fine.

What this is suppose to do is populate a table I made based on the
query with records for every day based on user start and end dates.
Each record from the query has a start and end date that will populate
the table with all information except the start and end date. In lieu
of start/end dates it will append a CalcDate based on the current date
in the loop.
QrySupportRpt:
SptState - state
SptType - type of support
StartDate - start date of support
EndDate - end date of support
PAX - number of personnel supporting
UIC - unit id code providing support

TblPaxReport:
SptState
SptType
CalcDate - Date providing support to state
PAX
UIC

Please advise of any modifications to this code I need to make to get
this to work.

Private Sub cmdReport_Click ()
On Error GoTo Err_cmdReport_C lick

Dim stPAXquery As String

stPAXquery = "QrySupport Rpt"

'Check values are entered into Date From and Date To text boxes
'if so run report or cancel request

If Len(Me.txtdatef rom & vbNullString) = 0 Or Len(Me.txtDateT o &
vbNullString) = 0 Then
MsgBox "Please ensure that a report date range is entered into
the form", _
vbInformation, "Required Data..."
Exit Sub
Else
DoCmd.OpenQuery stPAXquery
End If

On Error Resume Next

Dim CalcDate As Date

Dim PaxData As ADODB.Recordset

Dim strsql As String

Dim StartDate As Date

DoCmd.SetWarnin gs False
' cboTblPaxReport .SetFocus

' Delete records from table
DoCmd.Execute "Delete * from TblPaxReport"

Set CalcDate = Me.txtdatefrom

' Loop for record inside loop for date
' This keeps the dates grouped

If PaxData.RecordC ount <0 Then
Do Until CalcDate = Me.txtDateTo
PaxData.MoveFir st
Do Until PaxData.EOF
If CalcDate >= [StartDate] And CalcDate <= [EndDate] Or
CalcDate >= [StartDate] And [EndDate] Is Null Then
DoCmd.Execute "Insert into TblPaxReport (SptState,
SptType, CalcDate, PAX, UIC) values ()"
PaxData.MoveNex t
Else
Loop
Set CalcDate = DateAdd("d", 1, CalcDate)
Loop

Else
End If

Exit_cmdReport_ Click:
Exit Sub

Err_cmdReport_C lick:
MsgBox Err.Description
Resume Exit_cmdReport_ Click

End Sub

Sep 20 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
17916
by: CrystalDBA | last post by:
I am using SQL Server 2000. I need to query my database for all the contracts that came in during a certain time frame (user is prompted for reportingperiodid). Table - Periods Fields - Reporting Period id int Reporting Period desc varchar(30) Reporting Period Begin Date datetime Reporting Period End Date datetime
53
5749
by: Cardman | last post by:
Greetings, I am trying to solve a problem that has been inflicting my self created Order Forms for a long time, where the problem is that as I cannot reproduce this error myself, then it is difficult to know what is going on. One of these Order Forms you can see here... http://www.cardman.co.uk/orderform.php3
14
4359
by: Alan | last post by:
Hi everyone! I'm trying to produce a periodic financial report on projects from various departments. My database is set up with the tables tblDepartment, tblProjects, tblPeriods, and tblBudgets -- the first three serve the obvious function; the last table contains foreign keys to tblProjects and tblPeriods, each record corresponding to a project's budget for a particular period. Periods are also grouped by years (a seperate field for...
1
1980
by: Ladislau S. | last post by:
Dear reader, I am an occasional user of MS Access 2000 running on Windows 98. My hobby is ship model building so I made a database for things that I want to buy. After two strokes I bin unable to remember or find how to calculate the sum of the prices of a column. I made query to calculate the price of itch item (I have some multiple items). Whit this query I made a nice report, bat the best, how match is the price of my wish list I do...
1
4133
by: jaswmil | last post by:
I have a query (see SQL below) that essentially grabs a list of all employees terminated during a specific period. What I am needing to do is to be able to take this number and then divide it by the CURRENT count of active employees. The problem that I cannot figure out, is how do I do this by department. Of course all of our departments want to be able to see their own specific turnover rate. I can figure out how to do this on a...
4
3020
by: NormAmst | last post by:
I have a list of CPU processing times and job durations for an entire department at work. There are 3 classifications I am maintaining. CPU time during peak hours , CPU time during non peak hours and total CPU time. I developed an Excel spreadsheet totaling the times and manually format a spreadsheet to present total jobs run and total CPU time for the department. I also developed an Access 2002 db, where I import all the run job...
6
4892
by: Stuart Shay | last post by:
Hello All: I have a array which contains the totals for each month and from this array I want to get a running total for each month decimal month = new decimal; month = 254; (Jan) month = 78; (Feb) month = 34; (Mar) ect ...
4
4708
by: khicon73 | last post by:
Hello All, I would like to calculate weeknumber and period from first day of the week (sunday) and last day of the week (saturday) and week number falls from 1 to 52 only. If week number >= 53 then week number will equal to 52. And Last Day of First week is the first Saturday of January, as long as it falls at least four days into the month Example: if enter Date WeekNo. Period 12/31/06 1 12/31/06-01/06/07 01/05/07 1 12/31/06-01/06/07...
15
6443
by: student4lifer | last post by:
Hello, I have 2 time fields dynamically generated in format "m/d/y H:m". Could someone show me a good function to calculate the time interval difference in minutes? I played with strtotime() but but that only gave me difference in hours and only if the times were on the same day (after wrapping with date() function). TIA
0
9700
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9564
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10068
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9121
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7603
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6841
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5627
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4275
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.