Sked
Oct 17th, 1999, 09:04 AM
hi there,
i'm quite new to database programming in VB and im wondering whats the best way to total records. I have a database with like a hundred or so numeric fields, and i want to get a single record containg the totals of those fields. Right now i'm doing something like this: For X = 0 To 138
Set temp = dbs.OpenRecordset("select sum(" + mainrec.Fields(X).Name + ") as s from mdbtemp where year = '" + year + "'")
recs.Fields(X).Value = temp.Fields("s").Value
Next
which i believe is terrible and inefficient.
is there any easier way to do this like the "total" command in foxpro? thanks in advance.
i'm quite new to database programming in VB and im wondering whats the best way to total records. I have a database with like a hundred or so numeric fields, and i want to get a single record containg the totals of those fields. Right now i'm doing something like this: For X = 0 To 138
Set temp = dbs.OpenRecordset("select sum(" + mainrec.Fields(X).Name + ") as s from mdbtemp where year = '" + year + "'")
recs.Fields(X).Value = temp.Fields("s").Value
Next
which i believe is terrible and inefficient.
is there any easier way to do this like the "total" command in foxpro? thanks in advance.