I am using the following code in the OnCurrent event of a Subform
The code looks a the field Module Result and if the field is Null or = 0 it is ignored
else it increments a count
The problem is that if you select a record on the Mainform And the field Moduleresult for all the related records in the Sub form are 0 This error is produced
run time Error '6'
Over flow
Dim count As Integer
Dim total As Integer
Dim rst As Recordset
Set rst = Me.RecordsetClone
count = 0
total = 0
rst.MoveFirst
Do
If IsNull(rst!ModuleResult) Or rst!ModuleResult = 0 Then
'ignore result
Else
count = count + 1
total = total + rst!ModuleResult
End If
rst.MoveNext
Loop Until rst.EOF
Me!Average = total / count
Any ideas
The code looks a the field Module Result and if the field is Null or = 0 it is ignored
else it increments a count
The problem is that if you select a record on the Mainform And the field Moduleresult for all the related records in the Sub form are 0 This error is produced
run time Error '6'
Over flow
Dim count As Integer
Dim total As Integer
Dim rst As Recordset
Set rst = Me.RecordsetClone
count = 0
total = 0
rst.MoveFirst
Do
If IsNull(rst!ModuleResult) Or rst!ModuleResult = 0 Then
'ignore result
Else
count = count + 1
total = total + rst!ModuleResult
End If
rst.MoveNext
Loop Until rst.EOF
Me!Average = total / count
Any ideas