473,387 Members | 1,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How can I sum a column in database with a simple code?

t15, t14, t13, t12, t11, t10, t25, t24.... are the names of the datafield i dont know what to do. i tried many code examples but cant get it to work. i wnt to put one total to one text box. t15 is to txt15. help pls! :(
Oct 14 '09 #1
3 2548
smartchap
236 100+
Say rs is your recordset. First move recordset to the required record then you may use something like:

Total = Val(rs!t15) + Val(rs!t14) + Val(rs!t13) + Val(rs!t12) + Val(rs!t11) + Val(rs!t10) + Val(rs!t25) + Val(rs!t24)

and can show Total in a textbox. If already linked textboxes with fields then simply use code like:

Total = Val(txt15) + Val(txt14) + Val(txt13) + Val(txt12) + Val(txt11) + Val(txt10) + Val(txt25) + Val(txt24)
Oct 14 '09 #2
Here is my code and its finally working. my only problem now. is how can i add another column to add. and put it to another textbox



Private Sub Form_Load()

Dim MyCon As New ADODB.Connection
Dim jai As New ADODB.Recordset
Dim sConnect As String


sConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & _
App.Path & "\db1.mdb"

MyCon.Open sConnect
jai.Open "select sum(t15) from survey", MyCon, adOpenDynamic, adLockPessimistic
txt15.Text = jai.Fields(0)
jai.Close
MyCon.Close


End Sub
Oct 14 '09 #3
smartchap
236 100+
Dear
Your question not very clear. Please post zip file with exact problem, if not solved.
Dec 7 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: ssb | last post by:
Hello, This may be very elementary, but, need help because I am new to access programming. (1) Say, I have a column EMPLOYEE_NAME. How do I fetch (maybe, cursor ?) the values one by one and...
6
by: Robert Schuldenfrei | last post by:
Dear NG, After being away from C# programming for a spell, I am trying my hand at what should be a simple task. I have been hitting my head against the wall this morning. I have a simple order...
3
by: Daniel M | last post by:
I'm building a medium-scale data-entry web application, which involves creating data entry forms, record listings and detail screens for lots of database tables. Rather than designing a series...
0
by: ryan.d.rembaum | last post by:
I have posted q couple questions about databinding, but figured I'd simplify my questions and see if what I want to do is even possible. I have a database C:\mydatase.mdb In it there is a table...
3
by: jason | last post by:
I'll try to explain in detail what it is I'm struggling with. I created a SQL database with one table called CallSheet which contains the following columns: Caller ID: <--Primary Key, auto...
17
by: Benoit Martin | last post by:
I'm working on a project in VB.net connecting to a SQL Server 2000 database that I can't modify I created a dataset with a schema identical to the DB. When trying to update the DB from the dataset...
4
by: Frank | last post by:
Hello, I have a dataset with 2 tables and a relation (parent - child). I linked that ds to a datagrid. Shows everything fine (very little coding for such functionality!). But.. in the child row I...
5
by: minjie | last post by:
Is it possible to run a simple script to alter a table column in Access database from an interger to a double? I have been writing C++ programs every time we need to upgrade (modify) the Access...
6
by: Steve | last post by:
I realize that this probably isn't a best practice, but I'm working with legacy code that has a query stored in one column of a table. Because the queries vary, the JSP page that selects a query...
1
by: Frank Swarbrick | last post by:
We're trying to take advantage of the new ROW CHANGE TIMESTAMP option. Here is a simple table: CREATE TABLE "ACCTASGN"."NUMBER_STATUS" ( "STATUS_CODE" CHAR(1) NOT NULL , "STATUS_DESCRIPTION"...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.