By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,231 Members | 1,507 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,231 IT Pros & Developers. It's quick & easy.

counting/loops/adding records.

P: 2
I am working with an attendance database that holds records for each employee for when they are absent. For every 30 days WORKED for each employee I need to have the database automatically add a record. (it's an overly complicated attendance policy)
Can this be done with a query and SQL or will I have to code in VBA? I am not super proficient in this so any detailed help would be great. I know the syntax for adding records but am not sure how to code the loop that it counts the days for each employee separately.

I do have different Employee and Attendance tables.
Sep 25 '08 #1
Share this Question
Share on Google+
1 Reply

P: 167
In table Employee you need to have fields like:
WorkStart (Date - work starting date)
WorkEnd (Date - date employee left the employer)

In table Attendance you need a field:
LastLog (Date - date when last log was done)

1. You need to select all the employees currently working (WorkEnd is null) as a recordset
2. Loop through each of them using if statement like:
If Date - MyMax > 30 Then
Run update query here to add a new record

Note: MyMax is max LogDate from table attendance for that employee
Sep 25 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.