Hi Aqif:
Try the following function:
Function Prod(FieldName As String, TableQuery As String, Criteria As String)
‘This function returns a running product of the values in column [FieldName] located in the source table or query [TableQuery]
Dim db As Database
Dim rst As Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("SELECT " & FieldName & " FROM " & TableQuery & " WHERE " & Criteria)
Prod = 1
Do While Not rst.EOF
Prod = Prod * rst.Fields(0)
rst.MoveNext
Loop
End Function
Use the function like this in your QBE grid:
Product: Prod("FieldName","TableQuery","Autonumber < " & [Autonumber]+1)
Note: the table or query you´re using as a source (in this case “TableQuery”) MUST contain a unique index, and this field must be included in your query, the function uses this index (in this case field “Autonumber”) to loop through the recordset
Hope this helps.
Joey C.