[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Get sum of recordset

Posted on 2006-05-24
12
Medium Priority
?
372 Views
Last Modified: 2008-03-17
using VB
I query a access db from vb using adodc1.recordsource
Is it possible is there a comand to sum the values of one of the fields or do I have to write code that loops through each record?
something like this  .RecordSource = "select * from [Family History] sum[Orders]"
Where I can get the sum of all orders selected.
Thanks
0
Comment
Question by:whiwex
  • 6
  • 2
  • 2
  • +1
12 Comments
 
LVL 14

Expert Comment

by:dfu23
ID: 16755613
yes,

select * from [Family History] sum([Orders]) as SumOrders"
0
 
LVL 14

Accepted Solution

by:
dfu23 earned 2000 total points
ID: 16755624
oops,

select sum([Orders]) as SumOrders from [Family History]
0
 
LVL 2

Expert Comment

by:Ghasano
ID: 16755658
you can use like this :
if you are using access then :
CCur(Price) function
RecordSource = "SELECT COUNT* As FH ,SUM(" & CCur(Price) & ") AS Orders FROM Family History "
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 2

Expert Comment

by:Ghasano
ID: 16755662
sorry change it to
RecordSource = "SELECT * As FH ,SUM(" & CCur(Price) & ") AS Orders FROM Family History "
0
 
LVL 2

Expert Comment

by:Ghasano
ID: 16755675
you can have 2 commands from one sql string ..
the first will give you an information from all your fields that are in [familyHistory] and another alias name should give you the sum of orders
0
 
LVL 2

Expert Comment

by:Ghasano
ID: 16755678
change price field to your custom filed , may be orders
0
 
LVL 2

Expert Comment

by:Ghasano
ID: 16755681
sorry this is a conversion , bad day for me
0
 
LVL 2

Expert Comment

by:Ghasano
ID: 16755696
CCur() function , i use it to convert data which is stored as text to database so i conver to currency , after that ...sum ..
0
 

Author Comment

by:whiwex
ID: 16759909
I use this command but the sum is always zero.
select sum(Orders) as SumOrders from [Family History]
Don't know why
0
 
LVL 20

Expert Comment

by:Gawai
ID: 16760437
SumOrders field must be exit in your db to work
0
 
LVL 20

Expert Comment

by:Gawai
ID: 16760447
make sure SumOrders is existed in your db
0
 

Author Comment

by:whiwex
ID: 16760580
I found my problem. It's been a long copy of days
Thanks
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question