counting/loops/adding records.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kristilee
    New Member
    • Sep 2008
    • 2

    counting/loops/adding records.

    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.
  • hjozinovic
    New Member
    • Oct 2007
    • 167

    #2
    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

    Comment

    Working...