Hi,
I'm new to using this forum, and I hope I'm doing this right. I have an issue with a database I'm designing for a cadet corps. I'm trying to set it up so that it automatically calculates attendance on each parade night. First of all, here is the code.
Private Sub Form_Open(Cancel As Integer)
On Error GoTo Err_Form_Open
Dim nbrPresent, CountCadets, CountList, CadetsatPresent As Integer
Dim AttAverage As Double
Dim dbTraining As Object
Dim rstPresent As Object
Dim strAverage As String
Set dbTraining = CurrentDb
Set rstPresent = dbTraining.OpenRecordset("tblListofActivities")
CountList = DCount("[ActivityID]", "tblListofActivities")
CountCadets = DCount("[RecordID]", "tblCadetMain")
Select Case CountCadets
Case Is > 0
[Forms]![frmAttendance]![sfrmAttendanceCadets].SetFocus
DoCmd.GoToRecord , , acFirst
For I = 1 To CountList
CadetsatPresent = DCount("[RecordID]", "tblActivitiesCadets", "[ActivityID] =" & [Forms]![frmAttendance]![sfrmAttendanceCadets].[Form].ActivityID)
nbrPresent = DCount("[RecordID]", "tblActivitiesCadets", "[ActivityID] =" & [Forms]![frmAttendance]![sfrmAttendanceCadets].[Form].ActivityID & "AND [Present]=True")
rstPresent.Edit:
rstPresent("CadetsPresent").Value = nbrPresent:
rstPresent("CadetsCounted").Value = CadetsatPresent:
AttAverage = Round((nbrPresent / CadetsatPresent), 1) * 100:
strAverage = AttAverage & "%":
rstPresent("CadetAverage").Value = strAverage:
rstPresent.Update:
If I <> CountList Then
rstPresent.MoveNext
DoCmd.GoToRecord , , acNext
End If
Next I
DoCmd.GoToRecord , , acFirst
End Select
Exit_Form_Open:
Exit Sub
Err_Form_Open:
MsgBox Err.Description
Resume Exit_Form_Open
End Sub
Whenever I try to run this code, I get the following error:
Run Time Error '6'
Overflow
and the debugger points to the line highlighted in red. I even tried adding a button, and putting the code in the OnClick property, but it does the same thing. Does anybody know what this means and what I can do to solve it? Any help would be greatly appreciated.
Thank you.
Comtech