Well, as noted earlier, this is a problem because of the table structure.
If the table was more like
--PrimaryKey (This could be the combination of the next two fields and
therefore not needed as standalone field at all)
--ForeignKeyField (Points to original Table's Primary Key)
--ValueName (Name of field currently holding the value)
--Amount (Value currently stored in field)
Then getting the average, Max, min, sum, etc of those fields would be
straight forward in a query.
You could generalize the function a bit more if you table structure was such
that you had a primary key and the fields you were going to total were in
consecutive order. Then you could pass the tablename, primaryFieldName, a
primary key value, a start field position and a stop field position.
The SQL statement would be
"SELECT * FROM [" & strTableName & "] WHERE [" & strPrimaryField & "] = " &
PrimaryKeyValue
And the loop would run
For iLoop = IntStart To IntEnd
...
Next iLoop