Connecting Tech Pros Worldwide Help | Site Map

Make Average follow record

Newbie
 
Join Date: Nov 2006
Location: America
Posts: 12
#1: Nov 15 '06
Ok this works great, but which part of it can I change to make the "Average of the 10" stay with the current record. These averages are currently "logged" by hand, if I pull the records into a report, it will auto-log and no more human error

Private Sub cmdCalc_Click()
Dim tempTotal As Double
Dim tempVal As Double
Dim iCount As Integer
Dim i As Integer
tempTotal = 0
iCount = 0
For i = 1 To 10
tempVal = Nz(Me.Controls("Batch#" & i), 0)
If tempVal <> 0 Then
tempTotal = tempTotal + tempVal
iCount = iCount + 1
End If
Next i
Me.txtAverage = tempTotal / iCount
msquared's Avatar
Administrator
 
Join Date: Aug 2006
Location: Dublin, Ireland
Posts: 10,865
#2: Nov 16 '06

re: Make Average follow record


Create a field on the relevant table to store the value and then go to the txtAverage control in the form and in the properties window under the data tab set the control source to this field.

This will store the value with the record.

Mary

Quote:

Originally Posted by Del Cagle

Ok this works great, but which part of it can I change to make the "Average of the 10" stay with the current record. These averages are currently "logged" by hand, if I pull the records into a report, it will auto-log and no more human error

Private Sub cmdCalc_Click()
Dim tempTotal As Double
Dim tempVal As Double
Dim iCount As Integer
Dim i As Integer
tempTotal = 0
iCount = 0
For i = 1 To 10
tempVal = Nz(Me.Controls("Batch#" & i), 0)
If tempVal <> 0 Then
tempTotal = tempTotal + tempVal
iCount = iCount + 1
End If
Next i
Me.txtAverage = tempTotal / iCount

Newbie
 
Join Date: Nov 2006
Location: America
Posts: 12
#3: Nov 16 '06

re: Make Average follow record


Solved, thank you again :)
msquared's Avatar
Administrator
 
Join Date: Aug 2006
Location: Dublin, Ireland
Posts: 10,865
#4: Nov 16 '06

re: Make Average follow record


Quote:

Originally Posted by Del Cagle

Solved, thank you again :)

No problem.

Glad to help.
Reply