[AccessD] Changing table values via code

Josh McFarlane darsant at gmail.com
Wed Jun 29 08:44:37 CDT 2005


On 6/29/05, John Clark <John.Clark at niagaracounty.com> wrote:
> Hi everybody...long time since I've asked a question here, but I find
> myself needing help again.
> 
> I am working on a db for a payroll dept. One of the things I need to do
> for them is to keep a running total for time off. Basically each
> employee will have a record in a table with fields for vacation,
> personal, sick, etc., and I need to do two things with these numbers. I
> need to add to these totals at the beginning of each years, as they earn
> more time. And, I need to subtract from these totals as they use their
> time. So, when a payroll clerk enters a value of 7 hrs vacation for an
> employee on a given day, I need to subtract seven from their total
> vacation hours.
> 
> Both of these will be done via code, at the time of the change, but I
> have never done this before. I would appreciate any direction you could
> offer.

Well, it depends on how you're looking to do it, but you can
self-reference to get the effect you're looking for in the format of X
= X - Y

rs.Fields("VacationTime") = rs.Fields("VacationTime") - nhoursUsed
or if you have both values form named nVacationTime (bound) and
nHoursUsed (could be unbound or bound)
nVacationTime = nVacationTime - nHoursUsed
-- 
HTH
Josh McFarlane
"Peace cannot be kept by force. It can only be achieved by understanding."
-Albert Einstein



More information about the AccessD mailing list