View Full Version : calculated field


abieyuwae
01-06-2000, 02:51 PM
hi,
i have two text boxes.one have a default value of 8 (which is hours an employee can actually work)
the other is the hours absent.
what i'm trying to do is :
1. when i put a number in the hours absent, i want the value in the hours worked box to change.
right now, what i do is make a change each time an employee have some time off, which now makes the defualt value to chanege.
please is there a way i can make this simplier?
2. if maybe the hours absent was 2hours and the default value for hours worked is already set to 8, how do i make this value automatically change to 6hours, since the employee was out for 2hours.

Travis
01-06-2000, 10:52 PM
The answer is elementary (addition and subtraction that is Access Style)

On the AfterUpdate of the Hours Absent Field add this code.

Private Sub HoursAbsent_AfterUpdate()
Me.[HoursWorked]=Me.[HoursWorked].DefaultValue - Me.[HoursAbsent]
End Sub

Nice thing is that you can always retrieve the DefaultValue so if you change the Hours Absent you will get a valid Hours Worked.

Hope this helps

End Sub