calculated field (1 Viewer)

abieyuwae

New member
Local time
Today, 07:44
Joined
Oct 20, 1999
Messages
6
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

Registered User.
Local time
Yesterday, 23:44
Joined
Dec 17, 1999
Messages
1,332
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
 

Users who are viewing this thread

Top Bottom