Hello Everyone,
We are a dev team very new to Access, and so far we have gotten
excellent support from this group. We have a question about writing a
query. Here is the situation:
We have a query that pulls data from a detail table and displays the
total for 1 column.
DetailTable:
ProjectID (not unique)
EffectiveDate
TotalSalary
Query:
ProjectID (can have multiple records for the same ID)
EffectiveDate
SumofTotalSalary
That works. Simple enough!
Now, what we want is a query (may be we need another query or modify
this one), that:
A = Calculate days from effective date (Date minus EffectiveDate)
B = Multiply A with TotalSalary for each record
Show single record for each Project ID with the total of all Bs for
this ProjectID
Here is the query we have for the first part:
SELECT DISTINCTROW tblPersonnel.ProjectID, tblPersonnel.EffDate,
Sum(tblPersonnel.TotalSalary) AS [Sum Of TotalSalary]
FROM tblPersonnel
GROUP BY tblPersonnel.ProjectID, tblPersonnel.EffDate;
Here is the result we get:
"ProjectID","EffDate","Sum Of TotalSalary"
"J2006",8/1/2005 0:00:00,$115320.00
"P001",9/9/2006 0:00:00,$95020.00
"P007",1/1/2007 0:00:00,$82620.00
"P102",1/1/2007 0:00:00,$69300.00
"P110",1/1/2008 0:00:00,$55800.00
Thanks in advance for looking into this. You all are awsome.
Puneet. 3 4120 ac*******@gmail.com wrote in
news:11**********************@i42g2000cwa.googlegr oups.com:
Hello Everyone,
Now, what we want is a query (may be we need another query or
modify this one), that:
A = Calculate days from effective date (Date minus
EffectiveDate) B = Multiply A with TotalSalary for each record
Show single record for each Project ID with the total of all
Bs for this ProjectID
Here is the query we have for the first part:
SELECT DISTINCTROW tblPersonnel.ProjectID,
tblPersonnel.EffDate, Sum(tblPersonnel.TotalSalary) AS [Sum Of
TotalSalary] FROM tblPersonnel
GROUP BY tblPersonnel.ProjectID, tblPersonnel.EffDate;
Here is the result we get:
"ProjectID","EffDate","Sum Of TotalSalary"
"J2006",8/1/2005 0:00:00,$115320.00
"P001",9/9/2006 0:00:00,$95020.00
"P007",1/1/2007 0:00:00,$82620.00
"P102",1/1/2007 0:00:00,$69300.00
"P110",1/1/2008 0:00:00,$55800.00
Thanks in advance for looking into this. You all are awsome.
For the first step, you use the datediff() function.
datediff("d", effdate, date()). the "d" tells the function that
you want the difference in days. You could get months, weeks or
even seconds.
Note that since some of your dates are future, you'll want to
figure out some logic to exclude those dates else you'll have
negative days, and negative amounts..
An issue is the period of Salary. if it's by year, you will need
to divide by 365.
Then you insert all these expressions in the sum() function
above.
something like
sum(tblPersonnel.TotalSalary * iif(effdate date(), 0, datediff
( "d", effdate, date()) / 365) As [Sum Of Total Salary]
--
Bob Quintal
PA is y I've altered my email address.
--
Posted via a free Usenet account from http://www.teranews.com
Hi Bob,
That worked like a charm. Thanks.
However, I hvae a little complication to add, and I will explain by
example:
tblPersonnel:
ProjectID, ResourceID, BaseSalary, EffDate, PercentEffort, EffSalary,
Fringe, TotalSalary
P001, R990, 50000, 1/1/2006, 100, 50000, 10000, 60000
P001, R991, 60000, 1/1/2006, 100, 70000, 13000, 83000
P001, R990, 50000, 7/1/2006, 50, 25000, 10000, 35000
As you see, what is happening in this table via forms is --
In the beginning, R990 and R991 are at 100% effort on this project. So
their BaseSalary and EffSalary are same. Add some Fringe to it, and you
get the TotalSalary.
Now, effective 7/1/2006, R990 is changed from 100% to 50% effort.
Hence, the BaseSalary for this resource is down to 25000 and the
TotalSalary is 35000.
(I am creating a separate record every time the % Effort for the
resource is changed)
What I need to calculate is the total burn till date on the project for
all resources over the life of the project. So, if today is 8/3/2006,
it should come up to:
(60000/365) * DateDiff("d", 1/1/2006, 6/30/2006) +
(83000/365) * DateDiff("d", 1/1/2006, 8/3/2006) +
(35000/365) * DateDiff("d", 7/1/2006, 8/3/2006)
I just cant seem to figure out how to write this in the query. so for
example, in the first row of my sample calc above, how do I know if the
resource has another record from 7/1/2006, so only do 1/1 to 6/30....
Thanks again,
Puneet.
Bob Quintal wrote:
ac*******@gmail.com wrote in
news:11**********************@i42g2000cwa.googlegr oups.com:
Hello Everyone,
Now, what we want is a query (may be we need another query or
modify this one), that:
A = Calculate days from effective date (Date minus
EffectiveDate) B = Multiply A with TotalSalary for each record
Show single record for each Project ID with the total of all
Bs for this ProjectID
Here is the query we have for the first part:
SELECT DISTINCTROW tblPersonnel.ProjectID,
tblPersonnel.EffDate, Sum(tblPersonnel.TotalSalary) AS [Sum Of
TotalSalary] FROM tblPersonnel
GROUP BY tblPersonnel.ProjectID, tblPersonnel.EffDate;
Here is the result we get:
"ProjectID","EffDate","Sum Of TotalSalary"
"J2006",8/1/2005 0:00:00,$115320.00
"P001",9/9/2006 0:00:00,$95020.00
"P007",1/1/2007 0:00:00,$82620.00
"P102",1/1/2007 0:00:00,$69300.00
"P110",1/1/2008 0:00:00,$55800.00
Thanks in advance for looking into this. You all are awsome.
For the first step, you use the datediff() function.
datediff("d", effdate, date()). the "d" tells the function that
you want the difference in days. You could get months, weeks or
even seconds.
Note that since some of your dates are future, you'll want to
figure out some logic to exclude those dates else you'll have
negative days, and negative amounts..
An issue is the period of Salary. if it's by year, you will need
to divide by 365.
Then you insert all these expressions in the sum() function
above.
something like
sum(tblPersonnel.TotalSalary * iif(effdate date(), 0, datediff
( "d", effdate, date()) / 365) As [Sum Of Total Salary]
--
Bob Quintal
PA is y I've altered my email address.
--
Posted via a free Usenet account from http://www.teranews.com ac*******@gmail.com wrote in
news:11**********************@p79g2000cwp.googlegr oups.com:
Hi Bob,
That worked like a charm. Thanks.
However, I hvae a little complication to add, and I will
explain by example:
tblPersonnel:
ProjectID, ResourceID, BaseSalary, EffDate, PercentEffort,
EffSalary, Fringe, TotalSalary
P001, R990, 50000, 1/1/2006, 100, 50000, 10000, 60000
P001, R991, 60000, 1/1/2006, 100, 70000, 13000, 83000
P001, R990, 50000, 7/1/2006, 50, 25000, 10000, 35000
As you see, what is happening in this table via forms is --
In the beginning, R990 and R991 are at 100% effort on this
project. So their BaseSalary and EffSalary are same. Add some
Fringe to it, and you get the TotalSalary.
Now, effective 7/1/2006, R990 is changed from 100% to 50%
effort. Hence, the BaseSalary for this resource is down to
25000 and the TotalSalary is 35000.
(I am creating a separate record every time the % Effort for
the resource is changed)
What I need to calculate is the total burn till date on the
project for all resources over the life of the project. So, if
today is 8/3/2006, it should come up to:
(60000/365) * DateDiff("d", 1/1/2006, 6/30/2006) +
(83000/365) * DateDiff("d", 1/1/2006, 8/3/2006) +
(35000/365) * DateDiff("d", 7/1/2006, 8/3/2006)
I just cant seem to figure out how to write this in the query.
so for example, in the first row of my sample calc above, how
do I know if the resource has another record from 7/1/2006, so
only do 1/1 to 6/30....
Thanks again,
Puneet.
So what you need is a second date in the table. Instead of
EffDate, you need dteEffFrom and dteEffThru
Then you do another Iif to determine if dteEffThru is less than
today's date, and use that instead of today's date.
Then you sum the results.
-
Bob Quintal
PA is y I've altered my email address.
--
Posted via a free Usenet account from http://www.teranews.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Steve |
last post by:
Form FrmRestock's recordsource is QryFrmRestock. The TransactionDate field's
criteria is set ats:
Forms!FrmRestock!LastXDays. LastXDays on the form is a combobox where the
selections are 30, 60...
|
by: Andy |
last post by:
Hello,
I am having many problems with setting up a parameter query that
searches by the criteria entered or returns all records if nothing is
entered.
I have designed an unbound form with 3...
|
by: SuffrinMick |
last post by:
Hello - I'm a newbie to coding!
I'm working on an access 2000 database which has three tables:
tblContacts - A list of customer contacts.
tblOrgTypes - A list of organisational types....
|
by: Matthew |
last post by:
Hey ,
I have built a query which takes values from unbounded fields on a
form, and it all works except for one thing. I have a few fields in
my query that are dates. I also have a start and...
|
by: starace |
last post by:
I have designed a form that has 5 different list boxes where the
selections within each are used as criteria in building a dynamic
query. Some boxes are set for multiple selections but these list...
|
by: jquest |
last post by:
Hi Again;
I have had help from this group before and want to thank everyone,
especially PCDatasheet.
My database includes a field called HomePhone, it uses the (xxx)xxx-xxx
format to include...
|
by: MLH |
last post by:
I have an A97 query (qryVehiclesNowners2) that has a table
field in it named . Depending on the selections made
in a number of criteria choices on a form, a field on the form
will have string...
|
by: MLH |
last post by:
Am repeating question with different subject heading, perhaps
stating more clearly my problem...
I have an A97 query (qryVehiclesNowners2) that has a table
field in it named . Depending on the...
|
by: Thorben Grosser |
last post by:
Hello Newsgroup,
I am doing some archive database and therefore got one table indexing
every folder and one table storing which rack belongs to which
department, eg:
table folders :...
|
by: jmarcrum |
last post by:
Hi!
I have created a Union Query in ACCESS 2003, that combines 130 records from one query (Extra Foreman Radios) and 250 records from another query (Forman Main Radios). I have created a...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
|
by: Aliciasmith |
last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
|
by: giovanniandrean |
last post by:
The energy model is structured as follows and uses excel sheets to give input data:
1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
|
by: NeoPa |
last post by:
Hello everyone.
I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report).
I know it can be done by selecting :...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM)
Please note that the UK and Europe revert to winter time on...
|
by: isladogs |
last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, Mike...
|
by: GKJR |
last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
| |