Results 1 to 3 of 3

Thread: Adding Entries in a Column

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 1999
    Posts
    6

    Post

    Hello,
    I have a simple database program in which I want to add all the entries in a specific COLUMN and then put the value in a text box.
    I know that one way to do it is through SQL SUM command.I want to know whether there is a way to use Coulmns COllection in VB to achieve this,
    Thankx in advance....

  2. #2
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

    Post

    if you just want to display all of them, do this:
    (this uses ADO)

    dim cn as new connection
    dim rs as recordset
    dim I as long

    cn.open <connectionstringhere>
    set rs = cn.execute("Select <myfield> from <mytable> where <criteria>")
    do until rs.eof = true
    text1.text = text1.text & vbcrlf & rs.fields(0).value
    loop

    all done

    HTH

    Tom

  3. #3
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105

    Post

    Be much faster to do:

    sSQL= "select sum(column) from table"
    set rstemp= databaseobject.OpenRecordSet (sSQL)
    if rsTemp.EOF = False then ' there's entries to process
    form.text = rsTmp.Fields(0)
    else
    form.text = 0
    end if

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