Hi All,
How to run sum() Function in VB6?
Adodc1.recordso urce="select sum(quantity) from purchase"
adodc1.refresh
1.) but how to retrieve result in desired text box like i took- AvailabeQuantit y.Text
somewhere i read that query is like "Select sum(quantity) as SumOfQuantity from purchase"
2.) in above statement what is "as SumOfQuantity"
can you please help me
NE☼
13 23114
Hi All,
How to run sum() Function in VB6?
Adodc1.recordso urce="select sum(quantity) from purchase"
adodc1.refresh
1.) but how to retrieve result in desired text box like i took- AvailabeQuantit y.Text
somewhere i read that query is like "Select sum(quantity) as SumOfQuantity from purchase"
2.) in above statement what is "as SumOfQuantity"
can you please help me
NE☼
Hi ,
when you execute this query the quantity will be populated in the column named SumOfQuantity
-ansuman sahu
Hi All,
How to run sum() Function in VB6?
Adodc1.recordso urce="select sum(quantity) from purchase"
adodc1.refresh
1.) but how to retrieve result in desired text box like i took- AvailabeQuantit y.Text
somewhere i read that query is like "Select sum(quantity) as SumOfQuantity from purchase"
2.) in above statement what is "as SumOfQuantity"
can you please help me
NE☼
I am not sure about adodc control but if you can change to adodb connection then put down the code as below.
Also remove adodc and
add reference Microsoft Active X Data objects 2.0 library by clicking on Project--References
Now the code -
Dim MyCon As New ADODB.Connection
-
Dim Myrs As New ADODB.Recordset
-
Dim sConnect As String
-
-
-
sConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
-
"Data Source=" & _
-
App.Path & "emp.mdb"
-
'Replace emp with your file name
-
MyCon.Open sConnect
-
Myrs.Open "select sum(quantity) from purchase", MyCon, adOpenDynamic, adLockPessimistic
-
text1.text=Myrs.Fields(0)
-
Myrs.Close
-
MyCon.Close
it will display the result.
as far as as "SumOfQuant ity" it should be used in sql query statement in sql not in visual basic.
Thank you Sahu, Thank you Cmrehma,
I have total 4 fields in my 'Purchase' table -(product_id, product_name, quantity, price)
what should be code for sum(quantity) if i use Adodc connection.
i have tried --
adodc1.recordso urce="select sum(quantity) from purchase"
adodc1.refresh
now how to get result in a text box????????
I want to retrieve data into a text box. THIS IS WHAT I WANT
as you said Sahu, SumOfQuantity is column in which my result will be populated. so how a result will go to database table? moreover in the form of column?
as you said cmrehma, forgive me if i misspelt you,
you said ---------->adodc1.fields( 0)
but i dont find any method with adodc named "Fields" so I got an error.
can you please sort out my need.
NE☼
Thank you Sahu, Thank you Cmrehma,
I have total 4 fields in my 'Purchase' table -(product_id, product_name, quantity, price)
what should be code for sum(quantity) if i use Adodc connection.
i have tried --
adodc1.recordso urce="select sum(quantity) from purchase"
adodc1.refresh
now how to get result in a text box????????
I want to retrieve data into a text box. THIS IS WHAT I WANT
as you said Sahu, SumOfQuantity is column in which my result will be populated. so how a result will go to database table? moreover in the form of column?
as you said cmrehma, forgive me if i misspelt you,
you said ---------->adodc1.fields( 0)
but i dont find any method with adodc named "Fields" so I got an error.
can you please sort out my need.
NE☼
Check out the new reply. I replaced the old one
Check out the new reply. I replaced the old one
Thanx Cmrhema, I just check it out.
I am not sure about adodc control but if you can change to adodb connection then put down the code as below.
Also remove adodc and
add reference Microsoft Active X Data objects 2.0 library by clicking on Project--References
Now the code -
Dim MyCon As New ADODB.Connection
-
Dim Myrs As New ADODB.Recordset
-
Dim sConnect As String
-
-
-
sConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
-
"Data Source=" & _
-
App.Path & "emp.mdb"
-
'Replace emp with your file name
-
MyCon.Open sConnect
-
Myrs.Open "select sum(quantity) from purchase", MyCon, adOpenDynamic, adLockPessimistic
-
text1.text=Myrs.Fields(0)
-
Myrs.Close
-
MyCon.Close
it will display the result.
as far as as "SumOfQuant ity" it should be used in sql query statement in sql not in visual basic.
Thanx for your interest, I am new to VB and not used Adodb before.
I have used adodc in entier project.
Is it possible to change Adodc connection to Adodb for a piece of code
(As you are suggesting me)
If it is so, are you sure it would not affect rest of my project.
Cmrhema, I really appreciate your interest.
Even if you can't tell me about Adodc I thank you by heart.
NE☼
I am not sure about adodc control but if you can change to adodb connection then put down the code as below.
Also remove adodc and
add reference Microsoft Active X Data objects 2.0 library by clicking on Project--References
Now the code -
Dim MyCon As New ADODB.Connection
-
Dim Myrs As New ADODB.Recordset
-
Dim sConnect As String
-
-
-
sConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
-
"Data Source=" & _
-
App.Path & "emp.mdb"
-
'Replace emp with your file name
-
MyCon.Open sConnect
-
Myrs.Open "select sum(quantity) from purchase", MyCon, adOpenDynamic, adLockPessimistic
-
text1.text=Myrs.Fields(0)
-
Myrs.Close
-
MyCon.Close
it will display the result.
as far as as "SumOfQuant ity" it should be used in sql query statement in sql not in visual basic.
Hi Cmrhema, My reply had not been posted last time so I'm writing again.
I am very new to VB and never used Adodb before.
I have used Adodc only in my entire project.
Is it possible to use Adodb for a piece of code without affecting the rest of the project having code for Adodc.?
I appreciate your interest. Even if you cant tell me much about Adodc, I thank you by heart for your support.
NE☼
Thanx for your interest, I am new to VB and not used Adodb before.
I have used adodc in entier project.
Is it possible to change Adodc connection to Adodb for a piece of code
(As you are suggesting me)
If it is so, are you sure it would not affect rest of my project.
Cmrhema, I really appreciate your interest.
Even if you can't tell me about Adodc I thank you by heart.
NE☼
Usually it is not desirable to put both into one project. But because you have no choice go for it.
Check out the new reply. I replaced the old one
I am replying you 3rd time.
I dont know wht's the problem behind this but...
Actually Cmrhema, I have never used Adodb and my entire project is having Adodc connection.
So is it possible to use Adodb for a piece of code without affecting the Adodc code of rest of the project.
NE☼
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Ben |
last post by:
Hi all,
I'm trying to figure out how how complex map, filter and reduce work
based on the following piece of code from
http://www-106.ibm.com/developerworks/linux/library/l-prog.html :
bigmuls = lambda xs,ys: filter(lambda (x,y):x*y > 25, combine(xs,ys))
combine = lambda xs,ys: map(None, xs*len(ys), dupelms(ys,len(xs)))
dupelms = lambda lst,n: reduce(lambda s,t:s+t, map(lambda l,n=n:
*n, lst))
|
by: gooday |
last post by:
Table test2 has multiple amounts for each account, I would like to sum
the amounts for the same account and use the result to update the
variable 'tot_amount' in table test1. But SQL does not allow me to use
sum function in update. Is there any other way to do this? Thanks.
update test1
set tot_amount=sum(b.amount)
from test1 as a
join test2 as b
on a.acc_no=b.acc_no
|
by: un[real] |
last post by:
Like I said in the title, I have to calculate the sum of the numbers of
an interger with a recursive fonction.
Exemple: n=1255, sum= 1 + 2 + 5 + 5= 13
Do I have to use a string on can I use a simple cin ??
Thanks for your help !!
And sorry for my english :)
|
by: Scott Cannon |
last post by:
I am trying to query 3 tables all related by Clinet_ID. The Clients
table, Monthly_Expenses table and Monthly_Income table. Each client
can have 0>M instances of expenses, past due expenses, and income so I
am using the SUM aggregate function to get the totals for the
Monthly_Epenses.Amount, Monthly_Expenses.Past_Due_Amount, and
Monthly_Income.Amount.
Then problem I am having and cannot seem to resolve is that the
Monthly_Income is...
|
by: Paddy |
last post by:
I was browsing the Voidspace blog item on "Flattening Lists", and
followed up on the use of sum to do the flattening.
A solution was:
I would not have thought of using sum in this way. When I did help(sum)
the docstring was very number-centric: It went further, and precluded
its use on strings:
| |
by: dwasbig9 |
last post by:
Hi Group (fairly limited knowledge of Access and almost none of Access
VBA. Using Access 2003).
I need to sum time, I've found through the groups archive an sql
extract that led me to this
SELECT Format(Sum(Table2.time),"Short Time") AS SumOftime
FROM Table2;
Which works fine but the article also said I would need a Function to
|
by: n8kindt |
last post by:
i don't know what to do about this one. there are some very strange things going on. i have a continuous form with a bound textbox and a bound toggle button. the textbox is named "Payment" and the toggle is named "Apply." i want to have a textbox in the footer (named TotalPayment) that calculates the sum of whatever is in the textbox, provided that the bound toggle button is set to True. i created a function for this purpose. here it is:
...
|
by: bearophileHUGS |
last post by:
Empty Python lists don't know the type of the items it will
contain, so this sounds strange:
0
Because that may be an empty sequence of someobject:
0
In a statically typed language in that situation you may answer the
|
by: cnb |
last post by:
This must be because of implementation right? Shouldn't reduce be
faster since it iterates once over the list?
doesnt sum first construct the list then sum it?
-----------------------
reduce with named function: 37.9864357062
reduce with nested, named function: 39.4710288598
reduce with lambda: 39.2463927678
sum comprehension: 25.9530121845
|
by: azegurb |
last post by:
Hello, I have one question again
i created one table again and in this table i added some another options
for ex at the previous table there were only one problem sum of the dynamically added rows
in this beside sum i need to sum of the tax
for ex: in column1 i added 300 and into 2-nd column i Chose 10%
i would like when i chose from drop down box 10% Let in the 2-nd column appear 10% of the value which i addee first column
for ex...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |