Results 1 to 3 of 3

Thread: select sum in dao

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2001
    Location
    Philippines
    Posts
    101

    select sum in dao

    hi,

    how do i perform a select sum in DAO? I've tried using the code below but i received an error:

    sql="SElect sum(fieldname) as result from table1"
    returnvalue = Data1.Database.Execute(sql)

    Thanks in advance

  2. #2
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    And what, pray-tell, is the error ?
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  3. #3
    Hyperactive Member
    Join Date
    May 2001
    Location
    Beirut, Lebanon
    Posts
    318
    sql="SElect sum(fieldname) as result from table1"
    returnvalue = Data1.Database.Execute(sql)
    Do you know that "returnvalue" should be a recordset object?
    so what you should do is:

    VB Code:
    1. Set returnvalue = Data1.Database.Execute(sql)
    2. Debug.Print "The sum is: "; returnvalue("result")

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