Results 1 to 2 of 2

Thread: total in vb

  1. #1

    Thread Starter
    New Member
    Join Date
    May 1999
    Posts
    2

    Post

    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.

  2. #2
    New Member
    Join Date
    Oct 1999
    Posts
    6

    Post

    why don,t you use the SUM Command of SQL.Also you can put the contents of an entire column in a loop and total them.Another way is to total the record in the Data Report rather than anywhere else because that is where it is needed.There u can use the sum function.
    Hope this helps
    Last edited by chem1; Sep 12th, 2019 at 01:42 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width