Results 1 to 2 of 2

Thread: getting the sum in datagrid cell

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    /root/usr/local/bin
    Posts
    476

    getting the sum in datagrid cell

    hello there!
    how do i get the sum in datagrid e.g in cell(2) values are:
    600
    700
    200
    total=1500

    adodc1.recordsource ="select * from mytable where id_no=2"

    then i will pass sum in the label1.caption = total in datagrid.cell(8)

    tnx a lot

  2. #2
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: getting the sum in datagrid cell

    Learn how to use non databound ADo objects. Once you've set up the connection object (for sample its named conn) to get the sum...

    Code:
    Dim rs As ADODB.Recordset
    
    On Error Goto ErrHandler
       Set rs = conn.Execute("SELECT SUM(field_to_sum) AS mysum FROM mytable WHERE id_no=2")
       label1.Caption = rs.Fields("mysum").Value

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