R
Renee
Hello all,
The value I need to return is the total # of credits carried over into
the currently selected Biennium. Each biennium affects the next. I believe
this should be done in a loop starting from the oldest biennium on record for
the selected staff member and cycling though to the selected biennium. The
credits are calculated as follows, Grouped on the Biennium:
Sum(IIf([Completion_Date]>=[Biennium_Start] And
([Completion_Date]<=[Biennium_End]),[Credits],0)) AS Credits_Earned
Here is what I have started for the function:
Public Function GetCarryOver (Staff_ID As Long, Biennium As Long) As Long
‘This function uses the staff ID and selected Biennium to find and return
‘the carry over credits.
On Error GoTo GetCarryOver_Err
Dim rst As RecordSet
Dim strSQL As String
strSQL = “Select * from tbl_transcript WHERE tbl_transcript.staff_id = “
‘The next statement concatenates the staff_id argument value
‘with the SQL string and opens the recordset with that criterion.
set rst = CurrentDb.OpenRecordset (strSQL & staff_id)
Here is an outline of the Loop I am trying to write:
Bienniums = 2001 – 2002, 2003 – 2004, 2005 – 2006
Select the oldest Biennium with records for the selected Staff_ID
(example: 2001 - 2002)
1. Calculate the (Credits Earned) in this Biennium
2. Since this is the oldest Biennium
there are no (Credits Carried Over) from the previous biennium
3. If there are no credits carried over from the previous biennium
a. Determine if more that 16 credits were earned.
b. If (Currently Earned) > 16 Then
1. All (Currently Earned) credits over 16
are (Credits Carried Over) to the next
biennium.
Else 16 – (Currently Earned) = (Still Due)
4. If this biennium is the selected biennium, exit the loop, else
Go back into the loop selecting the next biennium (example: 2003 - 2004)
1. Calculate the (Credits Earned) in this biennium
2. If there are (Credits Carried Over) from the previous biennium
a. Determine amount (Due after Carry Over): 16 – (Credits Carried Over)
b. If (Due after Carry Over) <= 0 then
1. (Credits Earned) = (Credits Carried Over)
to the next biennium.
c. If (Due after Carry Over) >0 Then
2. (Due after Carry Over) – (Earned Credits) =
(Still Due)
iii. If (Still Due) <= 0 Then
a. (Earned Credits) – (Due after
Carry Over)
= (Credits Carried Over) to
the next biennium
b. Else (Credits Carried Over) = 0
3. If there are no credits carried over from the previous biennium
Determine if more that 16 credits were earned.
a. If (Currently Earned) > 16 Then
i. All (Currently Earned) credits over 16
are (Credits Carried Over) to the next
biennium.
Else 16 – (Currently Earned) = (Still Due)
4. If This Biennium is the selected biennium, exit the loop, else
Go back into the loop selecting the next biennium (example: 2005 - 2006)
The calculations are not the trouble, it is the Loop Syntax. How should I
structure a loop that will start with the oldest found biennium_start for the
selected staff_id and end after looping through the selected biennium,
finally returning the carry over credits for the selected biennium?
I hope this makes sense! Thank you in advance if you read this far!!
Sincerely,
Renee
The value I need to return is the total # of credits carried over into
the currently selected Biennium. Each biennium affects the next. I believe
this should be done in a loop starting from the oldest biennium on record for
the selected staff member and cycling though to the selected biennium. The
credits are calculated as follows, Grouped on the Biennium:
Sum(IIf([Completion_Date]>=[Biennium_Start] And
([Completion_Date]<=[Biennium_End]),[Credits],0)) AS Credits_Earned
Here is what I have started for the function:
Public Function GetCarryOver (Staff_ID As Long, Biennium As Long) As Long
‘This function uses the staff ID and selected Biennium to find and return
‘the carry over credits.
On Error GoTo GetCarryOver_Err
Dim rst As RecordSet
Dim strSQL As String
strSQL = “Select * from tbl_transcript WHERE tbl_transcript.staff_id = “
‘The next statement concatenates the staff_id argument value
‘with the SQL string and opens the recordset with that criterion.
set rst = CurrentDb.OpenRecordset (strSQL & staff_id)
Here is an outline of the Loop I am trying to write:
Bienniums = 2001 – 2002, 2003 – 2004, 2005 – 2006
Select the oldest Biennium with records for the selected Staff_ID
(example: 2001 - 2002)
1. Calculate the (Credits Earned) in this Biennium
2. Since this is the oldest Biennium
there are no (Credits Carried Over) from the previous biennium
3. If there are no credits carried over from the previous biennium
a. Determine if more that 16 credits were earned.
b. If (Currently Earned) > 16 Then
1. All (Currently Earned) credits over 16
are (Credits Carried Over) to the next
biennium.
Else 16 – (Currently Earned) = (Still Due)
4. If this biennium is the selected biennium, exit the loop, else
Go back into the loop selecting the next biennium (example: 2003 - 2004)
1. Calculate the (Credits Earned) in this biennium
2. If there are (Credits Carried Over) from the previous biennium
a. Determine amount (Due after Carry Over): 16 – (Credits Carried Over)
b. If (Due after Carry Over) <= 0 then
1. (Credits Earned) = (Credits Carried Over)
to the next biennium.
c. If (Due after Carry Over) >0 Then
2. (Due after Carry Over) – (Earned Credits) =
(Still Due)
iii. If (Still Due) <= 0 Then
a. (Earned Credits) – (Due after
Carry Over)
= (Credits Carried Over) to
the next biennium
b. Else (Credits Carried Over) = 0
3. If there are no credits carried over from the previous biennium
Determine if more that 16 credits were earned.
a. If (Currently Earned) > 16 Then
i. All (Currently Earned) credits over 16
are (Credits Carried Over) to the next
biennium.
Else 16 – (Currently Earned) = (Still Due)
4. If This Biennium is the selected biennium, exit the loop, else
Go back into the loop selecting the next biennium (example: 2005 - 2006)
The calculations are not the trouble, it is the Loop Syntax. How should I
structure a loop that will start with the oldest found biennium_start for the
selected staff_id and end after looping through the selected biennium,
finally returning the carry over credits for the selected biennium?
I hope this makes sense! Thank you in advance if you read this far!!
Sincerely,
Renee