Make Average follow record

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Del Cagle
    New Member
    • Nov 2006
    • 12

    #1

    Make Average follow record

    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
  • MMcCarthy
    Recognized Expert MVP
    • Aug 2006
    • 14387

    #2
    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

    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

    Comment

    • Del Cagle
      New Member
      • Nov 2006
      • 12

      #3
      Solved, thank you again :)

      Comment

      • MMcCarthy
        Recognized Expert MVP
        • Aug 2006
        • 14387

        #4
        Originally posted by Del Cagle
        Solved, thank you again :)
        No problem.

        Glad to help.

        Comment

        Working...