C
Christine Vollberg via AccessMonster.com
I have this report that is run from a cmd button. The click event contains
code that is suppose to determine whether or not the sentence is concurrent
or consecutive. If concurrent sets the TotalYears to the largest number of
years. If there are also consecutive sentences it needs to add the years
to the largest concurrent sentence. It works fine for concurrent sentences
but not for consecutive. I am not getting any errors either. Any help
would be greately appreciated. Here is the portion of the code that is
suppose to do the calculation:
Private Sub cmdUCD_Click()
Dim TotalMonths As Long
Dim SubTotal As Long
Dim TotalDays As Long
Dim Sent As Long
Dim rstDefCharge As Recordset
Dim rstConCons As Recordset
Dim db As DAO.Database
Dim TotalYears As Integer
Set db = DBEngine(0)(0)
Set rstConCons = db.OpenRecordset("Select * from
tblConcurentConsecutiveTable where PrimaryCaseNo = '" & Replace(Me!CaseNo,
"'", "''") & "' and ((DefendantId) = " & Str(Me!DefendantId) & ")",
dbOpenSnapshot)
Set rstDefCharge = db.OpenRecordset("Select * from tblDefChargesSentence
where CaseNo = '" & Replace(Me!CaseNo, "'", "''") & "' and ((DefendantId) =
" & Str(Me!DefendantId) & ")", dbOpenSnapshot)
SubTotal = 0
With rstConCons
Do Until .EOF
If rstConCons![ConConsecCaseNo] = rstDefCharge![CaseNo] Then
If rstDefCharge!ConcurrentSentence = True Then
TotalMonths = rstDefCharge!SentYrs * 12
TotalDays = rstDefCharge!SentDays / 30
If TotalMonths > rstDefCharge!SentMos Then
If TotalMonths > TotalDays Then
Sent = TotalMonths / 12
If Sent > SubTotal Then
SubTotal = Sent
End If
End If
End If
End If
End If
..MoveNext
Loop
Do Until .EOF
If rstConCons!ConConsecCaseNo = rstDefCharge!CaseNo Then
If rstDefCharge!ConsecutiveSentence = True Then
SubTotal = rstDefCharge!SentYrs + SubTotal
End If
End If
..MoveNext
Loop
End With
Me!TotalYears = SubTotal
code that is suppose to determine whether or not the sentence is concurrent
or consecutive. If concurrent sets the TotalYears to the largest number of
years. If there are also consecutive sentences it needs to add the years
to the largest concurrent sentence. It works fine for concurrent sentences
but not for consecutive. I am not getting any errors either. Any help
would be greately appreciated. Here is the portion of the code that is
suppose to do the calculation:
Private Sub cmdUCD_Click()
Dim TotalMonths As Long
Dim SubTotal As Long
Dim TotalDays As Long
Dim Sent As Long
Dim rstDefCharge As Recordset
Dim rstConCons As Recordset
Dim db As DAO.Database
Dim TotalYears As Integer
Set db = DBEngine(0)(0)
Set rstConCons = db.OpenRecordset("Select * from
tblConcurentConsecutiveTable where PrimaryCaseNo = '" & Replace(Me!CaseNo,
"'", "''") & "' and ((DefendantId) = " & Str(Me!DefendantId) & ")",
dbOpenSnapshot)
Set rstDefCharge = db.OpenRecordset("Select * from tblDefChargesSentence
where CaseNo = '" & Replace(Me!CaseNo, "'", "''") & "' and ((DefendantId) =
" & Str(Me!DefendantId) & ")", dbOpenSnapshot)
SubTotal = 0
With rstConCons
Do Until .EOF
If rstConCons![ConConsecCaseNo] = rstDefCharge![CaseNo] Then
If rstDefCharge!ConcurrentSentence = True Then
TotalMonths = rstDefCharge!SentYrs * 12
TotalDays = rstDefCharge!SentDays / 30
If TotalMonths > rstDefCharge!SentMos Then
If TotalMonths > TotalDays Then
Sent = TotalMonths / 12
If Sent > SubTotal Then
SubTotal = Sent
End If
End If
End If
End If
End If
..MoveNext
Loop
Do Until .EOF
If rstConCons!ConConsecCaseNo = rstDefCharge!CaseNo Then
If rstDefCharge!ConsecutiveSentence = True Then
SubTotal = rstDefCharge!SentYrs + SubTotal
End If
End If
..MoveNext
Loop
End With
Me!TotalYears = SubTotal