-
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....
-
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
-
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