C
Cameron
I have a database that hold works and the dates they started working for the
organization. The dates produce a seniority number and as a new employee
starts that number is updated automatically.
But when an employee quits then they become inactive and when that status
changes then the seniority is re-calculated on the list. However, I have been
having some trouble getting the resequence to work.
I basically do a query of all the active employees and organize them based
on the start dates. i then have step through the query and change the
seniority date. But everytime this is performed it misses values like it
didn't run properly.
Public Function SenRecalc()
Dim MyDB As Database
Dim Myrecords As Recordset
Dim records As Integer
Dim X As Integer
Dim mysql As String
' used to recalculate the seniority list when an hourly employee goes
inactive
'
' Set Search string
mysql = "SELECT SeniorityDate, SeniorityLevel FROM Employees WHERE
([Employees.SeniorityDate] <> Null)"
mysql = mysql & "AND (Employees.Active = true) AND (Employees.EmpType =
'H') AND (Employees.SeniorityDate <> ' ')"
mysql = mysql & "AND (employees.SeniorityList = true) ORDER BY
SeniorityDate, Name ASC;"
Set MyDB = CurrentDb
Set Myrecords = MyDB.OpenRecordset(mysql)
records = Myrecords.RecordCount
Myrecords.MoveFirst
For X = 1 To records
Myrecords.Edit
Myrecords!SeniorityLevel = X
Myrecords.Update
Myrecords.MoveNext
Next
Myrecords.Close
Could you help out and find out what I might be doing wrong?
organization. The dates produce a seniority number and as a new employee
starts that number is updated automatically.
But when an employee quits then they become inactive and when that status
changes then the seniority is re-calculated on the list. However, I have been
having some trouble getting the resequence to work.
I basically do a query of all the active employees and organize them based
on the start dates. i then have step through the query and change the
seniority date. But everytime this is performed it misses values like it
didn't run properly.
Public Function SenRecalc()
Dim MyDB As Database
Dim Myrecords As Recordset
Dim records As Integer
Dim X As Integer
Dim mysql As String
' used to recalculate the seniority list when an hourly employee goes
inactive
'
' Set Search string
mysql = "SELECT SeniorityDate, SeniorityLevel FROM Employees WHERE
([Employees.SeniorityDate] <> Null)"
mysql = mysql & "AND (Employees.Active = true) AND (Employees.EmpType =
'H') AND (Employees.SeniorityDate <> ' ')"
mysql = mysql & "AND (employees.SeniorityList = true) ORDER BY
SeniorityDate, Name ASC;"
Set MyDB = CurrentDb
Set Myrecords = MyDB.OpenRecordset(mysql)
records = Myrecords.RecordCount
Myrecords.MoveFirst
For X = 1 To records
Myrecords.Edit
Myrecords!SeniorityLevel = X
Myrecords.Update
Myrecords.MoveNext
Next
Myrecords.Close
Could you help out and find out what I might be doing wrong?