Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
I need a way to look at the occurances on my table and have 2 attendance points deducted after a period 60 calendar days.
SELECT tblEmpHistory.EmpID, Max(tblEmpHistory.actAction) AS oAction
FROM tblEmpHistory
WHERE (((tblEmpHistory.Action)<>"Deduct"))
GROUP BY tblEmpHistory.EmpID;
SELECT tblEmpHistory.EmpID, Max(tblEmpHistory.actAction) AS dAction
FROM tblEmpHistory
WHERE (((tblEmpHistory.Action)="Deduct"))
GROUP BY tblEmpHistory.EmpID;
SELECT qryMaxOccDates.EmpID, qryMaxOccDates.oAction, getMths([oAction]) AS Mths, nz([dAction],[oAction]) AS dtAction, IIf([oAction]>[dtAction],DateDiff("m",[oAction],Date())-1,DateDiff("m",[dtAction],Date())-1) AS dteAction
FROM qryMaxOccDates LEFT JOIN qryMaxDeductDate ON qryMaxOccDates.EmpID=qryMaxDeductDate.EmpID;
SELECT qryLAction.EmpID, qryLAction.oAction, qryLAction.Mths, qryLAction.dtAction, qryLAction.dteAction
FROM qryLAction
WHERE (((qryLAction.dteAction)>0));
Function getMths(sDte As Date) As Integer
Dim i As Integer
i = 0
Do While sDte < Date
sDte = DateAdd("m", 1, sDte)
i = i + 1
Loop
getMths = i - 1
End Function
Function updateTable()
Dim rst As DAO.Recordset
Dim rst2 As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("qryLastAction", dbOpenDynaset)
Set rst2 = CurrentDb.OpenRecordset("tblEmpHistory", dbOpenDynaset)
If rst.EOF Or rst.BOF Then
Exit Function
Else
rst.MoveFirst
Do Until rst.EOF
Select Case rst!Mths
Case 0, 1, 4, 7, 10
rst.MoveNext
Case 2, 3, 5, 6, 8, 9, 11, 12
rst2.AddNew
rst2!EmpID = rst!EmpID
rst2!actAction = DateSerial(Year(rst!oAction), Month(rst!oAction) + rst!Mths, Day(rst!oAction))
rst2!Action = "Deduct"
rst2.Update
rst.MoveNext
End Select
Loop
End If
End Function