C
Christine Vollberg via AccessMonster.com
Need help with a recordset error, may be going about this wrong but here is
what I need it to do, find all the records for a given defendant that are
concurrent and then give me the max of those records, then find any that
are consecutive and add it to that max. Then that number populates a text
box on my report. It will not do a thing but give this error of too few
parameters. Sorry for the length I wanted you to see the whole module.
Private Sub Report_Open(Cancel As Integer)
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
'Dim sSQL As String
Set db = DBEngine(0)(0)
Set rstConCons = db.OpenRecordset("Select * from
tblConcurentConsecutiveTable where PrimaryCaseNo = tblDefChargesSentence!
CaseNo", dbOpenSnapshot)
Set rstDefCharge = db.OpenRecordset("Select * from tblDefChargesSentence
where tblConcurentConsecutiveTable!PrimaryCaseNo = tblDefChargesSentence!
CaseNo and tblConsecutiveTable!DefendantId = DefendantId", dbOpenSnapshot)
SubTotal = 0
With rstConCons
Do Until .EOF
If tblConcurentConsecutiveTable![ConConsecCaseNo] = tblDefChargesSentence!
[CaseNo] Then
If tblDefChargesSentence!ConcurrentSentence = True Then
TotalMonths = tblDefChargesSentence!SentYrs * 12
TotalDays = tblDefChargesSentence!SentDays / 30
If TotalMonths > tblDefChargesSentence!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 tblConcurentConsecutiveTable!ConConsecCaseNo = tblDefChargesSentence!
CaseNo Then
If tblDefChargesSentence!ConsecutiveSentence = True Then
SubTotal = tblDefChargesSentence!SentYrs + SubTotal
End If
End If
..MoveNext
Loop
TotalYears = SubTotal
End With
End Sub
what I need it to do, find all the records for a given defendant that are
concurrent and then give me the max of those records, then find any that
are consecutive and add it to that max. Then that number populates a text
box on my report. It will not do a thing but give this error of too few
parameters. Sorry for the length I wanted you to see the whole module.
Private Sub Report_Open(Cancel As Integer)
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
'Dim sSQL As String
Set db = DBEngine(0)(0)
Set rstConCons = db.OpenRecordset("Select * from
tblConcurentConsecutiveTable where PrimaryCaseNo = tblDefChargesSentence!
CaseNo", dbOpenSnapshot)
Set rstDefCharge = db.OpenRecordset("Select * from tblDefChargesSentence
where tblConcurentConsecutiveTable!PrimaryCaseNo = tblDefChargesSentence!
CaseNo and tblConsecutiveTable!DefendantId = DefendantId", dbOpenSnapshot)
SubTotal = 0
With rstConCons
Do Until .EOF
If tblConcurentConsecutiveTable![ConConsecCaseNo] = tblDefChargesSentence!
[CaseNo] Then
If tblDefChargesSentence!ConcurrentSentence = True Then
TotalMonths = tblDefChargesSentence!SentYrs * 12
TotalDays = tblDefChargesSentence!SentDays / 30
If TotalMonths > tblDefChargesSentence!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 tblConcurentConsecutiveTable!ConConsecCaseNo = tblDefChargesSentence!
CaseNo Then
If tblDefChargesSentence!ConsecutiveSentence = True Then
SubTotal = tblDefChargesSentence!SentYrs + SubTotal
End If
End If
..MoveNext
Loop
TotalYears = SubTotal
End With
End Sub