Assuming you have a form where you update the pay rate for an employee, you
could put code in the form's after update event to create a new record in the
history table. In the history table, you will also need an "effective date"
so any payroll history reporting would know which history record to match up
with.
Now, here is why I suggest adding a field to the payroll posting table
rather than having a rate history table. You queries or code used in payroll
history would have to look in the history file for an employee, determine
whether the record in the history file is the correct record to use for the
date paid based on the history record's effective date. It may have to find
the correct record in history or if none match then use the current employee
record pay rate. This will complicate your reporting. If, on the other
hand, you had a field in the payroll posting table, you would not have to
worry about finding the correct rate for that payroll posting.
Sierras said:
Thanks. I think a paid history table is what I'm looking for as long the
field would populate itself with the currect rate rather than having to
edit each record seperately. Would it be possible to have an employee
table with the name and the current rate and have the history table
populate itself with this rate automatically? I'm not sure how to do this
automatically with just a click of a process button.
Thanks
Barry's solution is correct; however, a more simplistic approach would
be a
little denormalization. In you pay History table, just a field
[PAID_RATE].
When you process payroll update that field with the rate at which the
employee was paid.
I am sure there will be some purists who will flame me for this
suggestion,
but I think purists sometimes don't read the entire book. The skip the
part
about when and why you should denormalize. I would argue this is a good
case
for denormalization.
Sierras said:
Hi
Just trying to get ideas as to how to get around the problem of hourly
rate changes in a payroll type database. If I place the hourly rate of
the employee in the employee table, then it would be easy to get the
total
amount to pay the person based on the hours worked. But that would mess
up my history totals when running a query.
I guess I need to capture the rate being used for the employee for the
week worked and store it in a table so that any rate changes in the
furure
won't affect historical data.
Any ideas or examples of how to get around this?
Thanks