PDA

Click to See Complete Forum and Search --> : Adding Entries in a Column


chem1
Oct 28th, 1999, 11:27 AM
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....

Clunietp
Oct 28th, 1999, 09:06 PM
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

JHausmann
Oct 29th, 1999, 10:55 AM
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