1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
|
Public Function StudentLoop(monthly As Boolean, Optional Group As String, Optional YearEnd As Boolean) As Boolean
DoCmd.SetWarnings False
If Lookforfolder = True Then
Dim db As Database
Dim rs As Recordset
Dim strGroup As String
Dim strRole As String
Dim strLocationRegion As String
Dim blnLocationInd As Boolean
Dim Q As String
Dim blnYearEnd As Boolean
Set db = CurrentDb
Q = DLookup("CurrentQuarter", "DatabaseParameters")
'Checks to see if we are running reports for all commission recipients, or just specified individual (as determined by the presence of Group)
If Nz(Group, "") <> "" Then
' Running individual report
Set rs = db.OpenRecordset("SELECT tblStudents.Segment, tblStudents.Location, tblStudents.ROLE, " & _
"tblStudents.Group_FileNo, tblStudents.LastName, tblStudents.FirstName, tblStudents.SSO, tblStudents.Email, tblStudents.[ProcessReport Yes/No] " & _
"FROM tblStudents " & _
"WHERE (((tblStudents.[ProcessReport Yes/No])=True)) and tblStudents.Group_FileNo = " & Group)
Else
'Running report for all tblStudents with ProcessReport indicator turned on.
Set rs = db.OpenRecordset("SELECT tblStudents.Segment, tblStudents.Location, tblStudents.ROLE, " & _
"tblStudents.Group_FileNo, tblStudents.LastName, tblStudents.FirstName, tblStudents.SSO, tblStudents.Email, tblStudents.[ProcessReport Yes/No] " & _
"FROM tblStudents " & _
"WHERE (((tblStudents.[ProcessReport Yes/No])=True))")
End If
rs.MoveFirst
'See if we are running year end reports
If YearEnd = True Then
'Running year end - Check to see if we should run the year end calculations
If MsgBox("Year end calculations have to run one time, but it is not necessary to run each time if changes have not occured." & vbCrLf & "Do you want to run year end calculations?", vbYesNo) = vbYes Then
Call RunYearEndEarned(YearEnd)
End If
Do Until rs.EOF
Select Case rs!Role
Case "Intermediate"
Call YearEndReportLoop(rs!Group_FileNo, "Intermediate", YearEnd)
Call RunYearEndOutput(rs!LastName, rs!FirstName, "Intermediate", monthly)
Case "Advanced"
Call YearEndReportLoop(rs!Group_FileNo, "Advanced", rs!Location, True, YearEnd)
Call RunYearEndOutput(rs!LastName, rs!FirstName, "Advanced", monthly)
End Select
rs.MoveNext
Loop
Else
'Running monthly or quarterly reports
'Check the role for every person in the acquired recordset
Do Until rs.EOF
Select Case rs!Role
Case "Intermediate"
Call ReportLoop(rs!Group_FileNo, "Intermediate")
Call RunOutput(rs!LastName, rs!FirstName, "Intermediate", monthly)
Case "Advanced"
Call ReportLoop(rs!Group_FileNo, "Advanced", rs!Location, True)
Call RunOutput(rs!LastName, rs!FirstName, "Advanced", monthly)
End Select
rs.MoveNext
Loop
End If
End If
Set rs = Nothing
Set db = Nothing
If Err.Number = 0 Then StudentLoop = True
SysCmd acSysCmdSetStatus, "Ready"
End Function
Public Function YearEndReportLoop(Group As String, strType As String, Optional LocationRegion As String, Optional LocationInd As Boolean, Optional YearEnd As Boolean) As Boolean
'This sets the reports that are processed for each individual for year end.
Call RunYearEndPayrollSummary(Group, strType, LocationRegion, LocationInd)
Call RunYearEndCustomerSummaryIntermediate(Group, strType, LocationRegion, LocationInd)
Call RunYearEndSummaryIndividual(Group, strType, LocationRegion, LocationInd)
Call RunGridAssignments(Group, strType, LocationRegion, LocationInd)
Call RunNewSignings(Group, strType, LocationRegion, LocationInd)
Call RunMiscReport(Group, strType, LocationRegion, LocationInd, YearEnd)
End Function
|