Getting SQL Sum() in VB 3.0 
Author Message
 Getting SQL Sum() in VB 3.0

Dear all,

I am pretty new in VB and have just encountered a problem. I have the
following code in my program module :

sqlq1="SELECT Sum(Cost) FROM MONEY_ALLOCATION WHERE MONEY_ALLOCATION.Dept_Code='40'"
set Qry1=createdynaset(sqlq1)

Okay, my problem is how can I display the "Sum(Cost)" from Qry1?

sqlq1=string,
Qry1=dynaset

Thank you all for the helping hand!

Best regards,
Ben



Sat, 06 Feb 1999 03:00:00 GMT  
 Getting SQL Sum() in VB 3.0


Quote:
>Dear all,
>I am pretty new in VB and have just encountered a problem. I have the
>following code in my program module :
>sqlq1="SELECT Sum(Cost) FROM MONEY_ALLOCATION WHERE MONEY_ALLOCATION.Dept_Code='40'"
>set Qry1=createdynaset(sqlq1)
>Okay, my problem is how can I display the "Sum(Cost)" from Qry1?

Don't hold me to this, but I think you need to add this....
sqlq1="SELECT Sum(Cost) As BIGBUCKS FROM MONEY_ALLOCATION WHERE
MONEY_ALLOCATION.Dept_Code='40'"

set Qry1 = DB.CreateDynaset(sqlq1)
Text1.Text = Qry1("BIGBUCKS")

Ed Phillippe

Quote:
>Thank you all for the helping hand!
>Best regards,
>Ben

********************************************************
**  Southern Indiana Bass Fishing / Outdoor Software  **
**    HTTP://www.evansville.net/~dlion/mypage.htm    **
********************************************************


Sat, 06 Feb 1999 03:00:00 GMT  
 Getting SQL Sum() in VB 3.0

Quote:

> Dear all,

> I am pretty new in VB and have just encountered a problem. I have the
> following code in my program module :

> sqlq1="SELECT Sum(Cost) FROM MONEY_ALLOCATION WHERE MONEY_ALLOCATION.Dept_Code='40'"
> set Qry1=createdynaset(sqlq1)

> Okay, my problem is how can I display the "Sum(Cost)" from Qry1?

> sqlq1=string,
> Qry1=dynaset

> Thank you all for the helping hand!

> Best regards,
> Ben

Ben,

        Qry1.fields(0) will do it.  You can use field position as well
as fieldnames to describe fields.  The positions are 0-based.
--

Thanks,
Dave Verschleiser
Q&D Software Development - http://www.q-d.com
Creators of WebForms and WebMania!

=======================================================
For the best SHAREWARE on the Net, check out:

** The Shareware Central Interactive Catalog **
** http://www.q-d.com/swc.htm **

Shareware authors -- find out how to obtain a listing!
=======================================================



Sun, 07 Feb 1999 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Getting SQL sums with a twist

2. Getting the value of a Sum() in a SQL query

3. getting the exact time in VB 3.0

4. Getting Windows 95 user name with VB 3.0

5. VB 3.0 - Getting the address of a variable??

6. VB 3.0 PRO/EXCEL/DDE Getting info from different sheets

7. help getting access VB 3.0 system tables

8. Getting String in VB 3.0 from DLL

9. Getting the length of selected files in a File List Box (sum in bytes)

10. Record getting summed multiple times

11. VB 3.0 + SQL Server 7.0 + ODBC

12. Access 2.0/VB 3.0/SQL 6.5 simultaneous read problem

 

 
Powered by phpBB® Forum Software