C
Claire
I've tried to reply to the following pasted post, but for some reason the
group is spiting me, and it hasn't appeared all day long. So, if something
finally kicks in and all of these appear, I deeply apologize. That said, I'm
stuck, and keep hitting a wall, so would LOVE some more help on this issue.
I'm working on accruing vacation time. There are different levels of
vacation, and an employee can move to the next level after they've worked a
number of hours at their starting level (this number of hours varies by
level). Each level also has a different rate of accrual and a max number of
hours that can be accrued. Employees start at different levels, and there
are only a certain number of levels. And to make it even more exciting,
hourly and salaried workers have different accruals (salaried depending on
how long they've worked) .
Currently I have two tables, one for hourly and one for salaried, which list
the levels, an employee table with their exemption type (hourly or salaried),
hours worked at the current level carried in (from before this database),
vacation carried in (also from before the database), and starting level,
beginning and ending dates of employment, and a table which sums the
applicable hours for accrual and hours taken off, by employee #.
The Vacation level table looks like:
Level--# Hours before next level--Earn Rate----Earn Period---Max accumulated
1----------4,000---------------------1-----------50------------60
2----------6,000---------------------2-----------50------------120
3---------10,000---------------------3-----------50------------180
4-----------n/a-----------------------4-----------50------------240
My query in progress gives me the rate for level 4+ (these levels are
static), and just lists the rest at level 1 at this point, because I can't
figure out how to change rates without insane if statements in the where.
(ETO = earned time off, ie vacation)
SELECT [ETO Applicable Hours].[Employee #], [ETO Applicable Hours].[Employee
Name], Employees.Exemption, Employees.[Starting Rate], Employees.[2008ETO],
Employees.HoursCarriedIn, [ETO Applicable Hours].[Hours Worked], [ETO
Applicable Hours].[ETO Taken], tblHourlyETO_Levels.Hours_Earn_Rate
FROM tblHourlyETO_Levels, Employees INNER JOIN [ETO Applicable Hours] ON
Employees.EmpNum=[ETO Applicable Hours].[Employee #]
WHERE IIf(Employees.[Starting Rate]>3,Employees.[Starting
Rate]=tblHourlyETO_Levels.Level_Number,tblHourlyETO_Levels.Level_Number=1);
The following suggestions from Clifford get me the rate and allows for
changes in rate, but chooses it as if everyone starts at level 1, and the
levels are the total hours worked rather than what you need to work at EACH
level before moving to the next.
So, if you've read this far, thank you, and do you have any suggestions?
Thanks,
Claire
Hi Claire,
Nice question! I think I can help get you pointed in the right
direction, even with some assumptions I made about how the vacation accrual
works.
I created a table named "tblVacation_Levels" with the following fields:
Level_Number
Hours_High
Hours_Earn_Rate
Hours_Earn_Period
Maximum_Hours_Earnable
The table contains essentially the same data as you show, with a few
changes. The Hours_Earn_Period is to hold the 50 in your example. It is
better to put this information into the table than to "hard" code it. That
way you can have differing values for differing levels. And if it ever
changes you only have to change the data, not the query or other code. For
the Maximum_Hours_Earnable of level 4 I entered 2147483647, the maximum value
that can be stored in a long integer column. I also added an additional row,
containing all zeroes. This is needed in order to do a join on the table
with itself between one row and the succeeding row (i.e. level 0 is joined to
level 1). If you want to report people who have not yet worked, use a -1 in
the Hours_High in the level 0 row.
Next a query, named "qryEmployee Total Hours Worked", that summarizes
the total hours worked for each employee. Two columns in mine:
EmployeeID
Total_Hours_Worked
Presumedly you already have something similar.
Finally, the query that reports the vacation hours allowed for each
employee:
SELECT A.EmployeeID, A.Total_Hours_Worked,
.[Maximum_Hours_Earnable]+([Total_Hours_Worked]-.[Hours_High])*[C].[Hours_Earn_Rate]\[C].[Hours_Earn_Period]
AS Vacation_Hours_Temp,
IIf([Vacation_Hours_Temp]>[C].[Maximum_Hours_Earnable],[C].[Maximum_Hours_Earnable],[Vacation_Hours_Temp]) AS Vacation_Hours_Allowed
FROM [qryEmployee Total Hours Worked] AS A, tblVacation_Levels AS B,
tblVacation_Levels AS C
WHERE (((A.Total_Hours_Worked) Between .[Hours_High]+1 And
[C].[Hours_High]) AND ((C.Level_Number)=.[Level_Number]+1))
ORDER BY A.EmployeeID;
You will need to adapt for your table, query and column names. If you
have questions about that post back.
Hope this helps,
Clifford Bass
group is spiting me, and it hasn't appeared all day long. So, if something
finally kicks in and all of these appear, I deeply apologize. That said, I'm
stuck, and keep hitting a wall, so would LOVE some more help on this issue.
I'm working on accruing vacation time. There are different levels of
vacation, and an employee can move to the next level after they've worked a
number of hours at their starting level (this number of hours varies by
level). Each level also has a different rate of accrual and a max number of
hours that can be accrued. Employees start at different levels, and there
are only a certain number of levels. And to make it even more exciting,
hourly and salaried workers have different accruals (salaried depending on
how long they've worked) .
Currently I have two tables, one for hourly and one for salaried, which list
the levels, an employee table with their exemption type (hourly or salaried),
hours worked at the current level carried in (from before this database),
vacation carried in (also from before the database), and starting level,
beginning and ending dates of employment, and a table which sums the
applicable hours for accrual and hours taken off, by employee #.
The Vacation level table looks like:
Level--# Hours before next level--Earn Rate----Earn Period---Max accumulated
1----------4,000---------------------1-----------50------------60
2----------6,000---------------------2-----------50------------120
3---------10,000---------------------3-----------50------------180
4-----------n/a-----------------------4-----------50------------240
My query in progress gives me the rate for level 4+ (these levels are
static), and just lists the rest at level 1 at this point, because I can't
figure out how to change rates without insane if statements in the where.
(ETO = earned time off, ie vacation)
SELECT [ETO Applicable Hours].[Employee #], [ETO Applicable Hours].[Employee
Name], Employees.Exemption, Employees.[Starting Rate], Employees.[2008ETO],
Employees.HoursCarriedIn, [ETO Applicable Hours].[Hours Worked], [ETO
Applicable Hours].[ETO Taken], tblHourlyETO_Levels.Hours_Earn_Rate
FROM tblHourlyETO_Levels, Employees INNER JOIN [ETO Applicable Hours] ON
Employees.EmpNum=[ETO Applicable Hours].[Employee #]
WHERE IIf(Employees.[Starting Rate]>3,Employees.[Starting
Rate]=tblHourlyETO_Levels.Level_Number,tblHourlyETO_Levels.Level_Number=1);
The following suggestions from Clifford get me the rate and allows for
changes in rate, but chooses it as if everyone starts at level 1, and the
levels are the total hours worked rather than what you need to work at EACH
level before moving to the next.
So, if you've read this far, thank you, and do you have any suggestions?
Thanks,
Claire
Hi Claire,
Nice question! I think I can help get you pointed in the right
direction, even with some assumptions I made about how the vacation accrual
works.
I created a table named "tblVacation_Levels" with the following fields:
Level_Number
Hours_High
Hours_Earn_Rate
Hours_Earn_Period
Maximum_Hours_Earnable
The table contains essentially the same data as you show, with a few
changes. The Hours_Earn_Period is to hold the 50 in your example. It is
better to put this information into the table than to "hard" code it. That
way you can have differing values for differing levels. And if it ever
changes you only have to change the data, not the query or other code. For
the Maximum_Hours_Earnable of level 4 I entered 2147483647, the maximum value
that can be stored in a long integer column. I also added an additional row,
containing all zeroes. This is needed in order to do a join on the table
with itself between one row and the succeeding row (i.e. level 0 is joined to
level 1). If you want to report people who have not yet worked, use a -1 in
the Hours_High in the level 0 row.
Next a query, named "qryEmployee Total Hours Worked", that summarizes
the total hours worked for each employee. Two columns in mine:
EmployeeID
Total_Hours_Worked
Presumedly you already have something similar.
Finally, the query that reports the vacation hours allowed for each
employee:
SELECT A.EmployeeID, A.Total_Hours_Worked,
.[Maximum_Hours_Earnable]+([Total_Hours_Worked]-.[Hours_High])*[C].[Hours_Earn_Rate]\[C].[Hours_Earn_Period]
AS Vacation_Hours_Temp,
IIf([Vacation_Hours_Temp]>[C].[Maximum_Hours_Earnable],[C].[Maximum_Hours_Earnable],[Vacation_Hours_Temp]) AS Vacation_Hours_Allowed
FROM [qryEmployee Total Hours Worked] AS A, tblVacation_Levels AS B,
tblVacation_Levels AS C
WHERE (((A.Total_Hours_Worked) Between .[Hours_High]+1 And
[C].[Hours_High]) AND ((C.Level_Number)=.[Level_Number]+1))
ORDER BY A.EmployeeID;
You will need to adapt for your table, query and column names. If you
have questions about that post back.
Hope this helps,
Clifford Bass