Hi All,
How to run sum() Function in VB6?
Adodc1.recordsource="select sum(quantity) from purchase"
adodc1.refresh
1.) but how to retrieve result in desired text box like i took- AvailabeQuantity.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 22950
Hi All,
How to run sum() Function in VB6?
Adodc1.recordsource="select sum(quantity) from purchase"
adodc1.refresh
1.) but how to retrieve result in desired text box like i took- AvailabeQuantity.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.recordsource="select sum(quantity) from purchase"
adodc1.refresh
1.) but how to retrieve result in desired text box like i took- AvailabeQuantity.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 "SumOfQuantity" 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.recordsource="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.recordsource="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 "SumOfQuantity" 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 "SumOfQuantity" 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☼
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☼
lookup the previous replu
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☼
lookup the previous reply
Dear Cmrhema,
it's giving error message : "Not a valid file name."
I have put 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 & "E:\Projects\Rishika Enterprises Project\Database\Rishika070601.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
When I put only Database file name "Rishika070601.mdb" it says can not find file E:\VBProjects\InventoryRishika07061.mdb
Hi Cmrhema,
It's working now.
Thanx a lot. Actually I'm from embedded side and new to VB that's why troubled you so much.
I appreciate your helping nature.
-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 :
...
|
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...
|
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...
|
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...
|
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...
|
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
...
|
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...
|
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...
|
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...
|
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...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |