Public Function ProcessReportInfo(StrEmpNum, StrLast, StrFirst)
Dim StrDeptAbs As String
Dim StrDeptTot As String
Dim RstDeptVac As Recordset
Dim RstDeptAbs As Recordset
Dim RstDeptTot As Recordset
Dim StrDeptNum As String
Dim StrDeptDate As String
Dim DeptCount As Integer
Dim VacCount As Integer
Dim AbsCount As Integer
Dim DeptLeftover As String
Dim DeptEarned As String
Dim DeptAccrued As String
Dim DeptTotal As String
Dim MyDb As Database
Dim AbsCode As String
Dim TotTotal As String
Dim DeptEmpName As String
Dim RstInsertDept As Recordset
Dim StrInsertDept As String
Dim QdfInsert As QueryDef
Dim WrkspcInsert As Workspace
StrDeptDate = #1/1/2003#
Set MyDb = CurrentDb
StrDeptTot = " Select Name, Leftover, Earned2003, AccruedHours, TotalHours From TotVacation where ID = " & StrEmpNum & ""
Set RstDeptTot = MyDb.OpenRecordset(StrDeptTot, dbOpenSnapshot)
If Not RstDeptTot.BOF And Not RstDeptTot.EOF Then
DeptEmpName = RstDeptTot!Name
DeptLeftover = RstDeptTot!Leftover
DeptEarned = RstDeptTot!Earned2003
DeptAccrued = RstDeptTot!AccruedHours
DeptTotal = RstDeptTot!TotalHours
StrDeptAbs = "SELECT Absence.EmpNum, Absence.AbsDate, Absence.AbsCode, Absence.WorkShift, Absence.AbsHours " & _
"FROM ABSENCE WHERE (((Absence.EmpNum)= " & StrEmpNum & "

AND(((Absence.AbsDate)>'" & StrDeptDate & "') AND ((((Absence.AbsCode)=87))" & _
"OR (((Absence.AbsCode)=88)) OR (((Absence.AbsCode)=89)) OR (((Absence.AbsCode)=90)) OR (((Absence.AbsCode)=91)))))" & _
"Order by AbsDate Desc"
' MsgBox " Sql Looks like " & StrDeptAbs & " This", vbOKOnly
Set RstDeptAbs = gconAbs.OpenRecordset(StrDeptAbs, dbOpenDynamic)
If Not RstDeptAbs.BOF And Not RstDeptAbs.EOF Then
DeptCount = 1
Do While DeptCount <= RstDeptAbs.RecordCount
If Not IsNull(RstDeptAbs!AbsHours) Then
AbsCode = RstDeptAbs!AbsCode
Select Case AbsCode
Case 87
DeptLeftover = DeptLeftover - RstDeptAbs!AbsHours
Case 88
DeptEarned = DeptEarned - RstDeptAbs!AbsHours
TotDept03Used = TotDept03Used + RstDeptAbs!AbsHours
Case 89
DeptEarned = DeptEarned - RstDeptAbs!AbsHours
TotDept03Cashed = TotDept03Cashed + RstDeptAbs!AbsHours
Case 90
DeptAccrued = DeptAccrued - RstDeptAbs!AbsHours
TotDeptAccUsed = TotDeptAccUsed + RstDeptAbs!AbsHours
Case 91
DeptAccrued = DeptAccrued - RstDeptAbs!AbsHours
TotDeptAccCashed = TotDeptAccCashed + RstDeptAbs!AbsHours
End Select
DeptTotal = DeptTotal - RstDeptAbs!AbsHours
Else
End If
DeptCount = DeptCount + 1
RstDeptAbs.MoveNext
Loop
StrInsertDept = "Insert Into tblTempDeptVac (" & StrEmpNum & " ," & StrLast & "," & StrFirst & ", " & _
" " & DeptLeftover & "," & DeptEarned & "," & TotDept03Used & "," & TotDept03Cashed & ", " & _
" " & DeptAccrued & "," & TotDeptAccUsed & "," & TotDeptAccCashed & "," & DeptTotal & "

"
If Not RunSql(StrInsertDept) Then
MsgBox "Error Has Occured entering info into Temp Table", vbOKOnly
Else
Call ClearAllTotals
End If
Else
' StrInsertDept = "Insert into Vacation Values ( '1','Reno','3','4','5')"
' StrInsertDept = "Insert into tblTempDeptVac Values ('1234','smith','mary','1','2','3','4','5','6','7','8')"
StrInsertDept = " Insert into tblTempDeptVac Values (' " & StrEmpNum & " ',' " & StrLast & " ',' " & StrFirst & " '," & _
" ' " & DeptLeftover & " ',' " & DeptEarned & " ','0','0', ' " & DeptAccrued & " ','0','0',' " & DeptTotal & " ' )"
End If
If Not RunSql(StrInsertDept) Then
MsgBox " Looks like " & StrInsertDept & " this", vbOKOnly
MsgBox "Error Has Occured. Temp Table 002", vbOKOnly
Else
Call ClearAllTotals
End If
End If
End Function
Public Function GetEmployeeFromDeptNum()
Dim StrDeptVac As String
Dim RstDeptVac As Recordset
Dim StrDeptNum As String
Dim StrEmpNum As String
Dim StrLast As String
Dim StrFirst As String
Dim VacCount As Integer
StrDeptNum = GetDeptNumber
If Not DbConnect(False) Then ' force a reconnect
MsgBox "Connection Lost, Please Contact IT", vbOKOnly
Else
StrDeptVac = "Select EmpNum, LastName, FirstName From Employees where Dept = " & StrDeptNum & ""
Set RstDeptVac = gconAbs.OpenRecordset(StrDeptVac, dbOpenDynamic)
If RstDeptVac.BOF And RstDeptVac.EOF Then
MsgBox " Cannot find employees for this Department " & StrDeptNum & " Try Again", vbOKOnly
Else
RstDeptVac.MoveFirst
If Not RstDeptVac.EOF And Not RstDeptVac.BOF Then
Do While Not RstDeptVac.EOF And Not RstDeptVac.BOF
VacCount = 1
StrEmpNum = RstDeptVac!EmpNum
StrLast = RstDeptVac!LastName
StrFirst = RstDeptVac!FirstName
Call ProcessReportInfo(StrEmpNum, StrLast, StrFirst)
RstDeptVac.MoveNext
VacCount = VacCount + 1
Loop
Else
End If
End If
End If
End Function