C
Claire
I am just starting a foray into VBA, and am stuck right at the beginning.
My goal is to total some fields in one table, for each employee, and to add
these totals to a different table, with some information from previous
records in the second table incorporated. How can I get access to select all
of the records in table one, the most recent for each employee in table two,
and then combine them? (some will write as is, others add, others subtract,
etc.)
Is there a way to loop through each record from a select statement? I'm at
a loss for what the syntax is, or where to find examples of the syntax.
If more details would be helpful, here's the basics of the tables:
tblHours
EmployeeID----Date----Hrs----Type
A-----------1/1/09-----6--------Regular
A-----------1/1/09-----2--------Vacation
A-----------1/2/09-----8--------Overtime
B-----------1/1/09-----8--------Regular
tblEmployees
EmployeeID--------Dept---------VacRate
A-------------------sales-----------2
B-------------------admin----------3
tblHistor
EmployeeID---Dept---PayrollEnding-------RegularHrs------OvertimeHrs-----VacationHrs------LifetimeHrs------VacationEarned---------VacationBalanc
A--------------sales-------1/2/09-------------6------------------8-------------------2------------------150--------------2-----------------------1
B--------------admin------1/2/09-------------8------------------0-------------------0-------------------100-------------1-----------------------12
I need to total each employees' hours in tblHours for a week, put these in
tblHistory fields, add them to LifetimeHrs, multiply some of them by their
VacRate(from tblEmployees) to get VacationEarned, and add VacationEarned and
subtract VacationHrs to get the VacationBalance.
I have a good idea of how to write the code for each element, ie which field
is getting multiplied by each and which is getting entered where, but I do
not know how to set up the skeleton. The whole part of selecting these
records and doing something with each of them (or, you know, with the sum of
them).
Thanks for any help you have. Anything described here or a link to some
basics on this kind of VBA would be GREATLY appreciated!
~Claire
My goal is to total some fields in one table, for each employee, and to add
these totals to a different table, with some information from previous
records in the second table incorporated. How can I get access to select all
of the records in table one, the most recent for each employee in table two,
and then combine them? (some will write as is, others add, others subtract,
etc.)
Is there a way to loop through each record from a select statement? I'm at
a loss for what the syntax is, or where to find examples of the syntax.
If more details would be helpful, here's the basics of the tables:
tblHours
EmployeeID----Date----Hrs----Type
A-----------1/1/09-----6--------Regular
A-----------1/1/09-----2--------Vacation
A-----------1/2/09-----8--------Overtime
B-----------1/1/09-----8--------Regular
tblEmployees
EmployeeID--------Dept---------VacRate
A-------------------sales-----------2
B-------------------admin----------3
tblHistor
EmployeeID---Dept---PayrollEnding-------RegularHrs------OvertimeHrs-----VacationHrs------LifetimeHrs------VacationEarned---------VacationBalanc
A--------------sales-------1/2/09-------------6------------------8-------------------2------------------150--------------2-----------------------1
B--------------admin------1/2/09-------------8------------------0-------------------0-------------------100-------------1-----------------------12
I need to total each employees' hours in tblHours for a week, put these in
tblHistory fields, add them to LifetimeHrs, multiply some of them by their
VacRate(from tblEmployees) to get VacationEarned, and add VacationEarned and
subtract VacationHrs to get the VacationBalance.
I have a good idea of how to write the code for each element, ie which field
is getting multiplied by each and which is getting entered where, but I do
not know how to set up the skeleton. The whole part of selecting these
records and doing something with each of them (or, you know, with the sum of
them).
Thanks for any help you have. Anything described here or a link to some
basics on this kind of VBA would be GREATLY appreciated!
~Claire