Error Number

Neo

Registered User.
Local time
Today, 16:56
Joined
Mar 5, 2003
Messages
42
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
 
neo,

Code:
If count = 0 Then
   Me!Average = 0
Else
   Me!Average = total / count 
End If

Wayne
 

Users who are viewing this thread

Back
Top Bottom