In case this helps, here is the SQL from the recordsource
query and the VBA code from the form used to trigger the
loop.....
***********************************************
SELECT Roster.Emp_Name, Service_Codes.CommBucket,
Sheet1.Check_In_Date, Sheet1.Accountnbr, Sheet1.Srv_Code,
Plans.table, Roster.Relief, Sheet1.CommissionAmount,
Sheet1.WidgetCount
FROM Plans INNER JOIN ((Sheet1 INNER JOIN Service_Codes ON
Sheet1.Srv_Code = Service_Codes.Srv_Code) INNER JOIN
Roster ON Sheet1.Social_Security_Nbr = Roster.Empl_ID) ON
Plans.Plan = Roster.FT_PT
WHERE (((Service_Codes.CommBucket)>0))
ORDER BY Roster.Emp_Name, Service_Codes.CommBucket,
Sheet1.Check_In_Date, Sheet1.Accountnbr;
***********************************************
Here is also the VBA used in the form's module set:
***********************************************
-----------------------------------
Option Compare Database
Dim Bucket As Byte
Dim RunningSumCount As Single
Dim Thresh_Quota As Single
Dim Goal_Quota As Single
Dim Stretch_Quota As Single
Dim Super_Quota As Single
Dim Thresh_Comm As Currency
Dim Goal_Comm As Currency
Dim Stretch_Comm As Currency
Dim Super_Comm As Currency
Dim Thresh_Pay As Currency
Dim Goal_Pay As Currency
Dim Stretch_Pay As Currency
Dim Super_Pay As Currency
Dim Total_Pay As Currency
-----------------------------------
Private Sub Form_Current()
Startoff:
If [CommBucket] = Bucket Then
RunningSumCount = RunningSumCount + 1
If (RunningSumCount - Thresh_Quota) < 1 And
(RunningSumCount - Thresh_Quota) > 0 Then
Thresh_Pay = (RunningSumCount - Thresh_Quota) *
Thresh_Comm
ElseIf (RunningSumCount - Thresh_Quota) <=
(Goal_Quota - Thresh_Quota) And (RunningSumCount -
Thresh_Quota) >= 1 Then
Thresh_Pay = Thresh_Comm
ElseIf (RunningSumCount - Goal_Quota) < 1 And
(RunningSumCount - Goal_Quota) > 0 Then
Thresh_Pay = (Abs(RunningSumCount - Goal_Quota -
1)) * Thresh_Comm
Else
Thresh_Pay = 0
End If
If (RunningSumCount - Goal_Quota) < 1 And
(RunningSumCount - Goal_Quota) > 0 Then
Goal_Pay = (RunningSumCount - Goal_Quota) *
Goal_Comm
ElseIf (RunningSumCount - Goal_Quota) <=
(Stretch_Quota - Goal_Quota) And (RunningSumCount -
Goal_Quota) >= 1 Then
Goal_Pay = Goal_Comm
ElseIf (RunningSumCount - Stretch_Quota) < 1 And
(RunningSumCount - Stretch_Quota) > 0 Then
Goal_Pay = (Abs(RunningSumCount - Stretch_Quota -
1)) * Goal_Comm
Else
Goal_Pay = 0
End If
If (RunningSumCount - Stretch_Quota) < 1 And
(RunningSumCount - Stretch_Quota) > 0 Then
Stretch_Pay = (RunningSumCount - Stretch_Quota) *
Stretch_Comm
ElseIf (RunningSumCount - Stretch_Quota) <=
(Super_Quota - Stretch_Quota) And (RunningSumCount -
Stretch_Quota) >= 1 Then
Stretch_Pay = Stretch_Comm
ElseIf (RunningSumCount - Super_Quota) < 1 And
(RunningSumCount - Super_Quota) > 0 Then
Stretch_Pay = (Abs(RunningSumCount - Super_Quota -
1)) * Stretch_Comm
Else
Stretch_Pay = 0
End If
If (RunningSumCount - Super_Quota) < 1 And
(RunningSumCount - Super_Quota) > 0 Then
Super_Pay = (RunningSumCount - Super_Quota) *
Super_Comm
ElseIf (RunningSumCount - Super_Quota) > 0.99 Then
Super_Pay = Super_Comm
Else
Super_Pay = 0
End If
Total_Pay = Thresh_Pay + Goal_Pay + Stretch_Pay +
Super_Pay
Else
RunningSumCount = 0
Bucket = CommBucket
Thresh_Quota = Nz(((DLookup("[Thresh_Quota]",
,
& ".id=" & [CommBucket])) * [Relief]) - [Relief])
Goal_Quota = Nz(((DLookup("[Goal_Quota]",
,
& ".id=" & [CommBucket])) * [Relief]) - [Relief])
Stretch_Quota = Nz(((DLookup("[Stretch_Quota]",
,
& ".id=" & [CommBucket])) * [Relief]) -
[Relief])
Super_Quota = Nz(((DLookup("[Super_Quota]",
,
& ".id=" & [CommBucket])) * [Relief]) - [Relief])
Thresh_Comm = Nz((DLookup("[thresh_Commission]",
,
& ".id=" & [CommBucket])))
Goal_Comm = Nz((DLookup("[goal_Commission]",
,
& ".id=" & [CommBucket])))
Stretch_Comm = Nz((DLookup("[stretch_Commission]",
,
& ".id=" & [CommBucket])))
Super_Comm = Nz((DLookup("[super_Commission]",
,
& ".id=" & [CommBucket])))
GoTo Startoff
End If
WidgetCount = RunningSumCount
CommissionAmount = Total_Pay
DoCmd.GoToRecord acDataForm, "Form1", acNext
End Sub
-----------------------------------
Private Sub Form_Open(Cancel As Integer)
Bucket = 0
End Sub
***********************************************