Now I want to view the customer Sneha's details. So I use the querry and got the following details:
Sneha Plastics 100
Sneha Plastics 300
How to get this total in a text box?
Could somebody help me?
Regards.
____________________________
Sneha
28-03-2006 at 02:59 PM
|
GeoffS Level: VB Lord Registered: 29-09-2004 Posts: 536
Re: How can I get the total of searched result in Datagrid?
Hi sneha,
I am assuming that you have fetched your query results into a Recordset object, so all you have to do is Loop through the Recordset adding the quantities to a variable.
Dim lngTotal As Long
lngTotal = 0
rstCustomers.MoveFirst
Do Until rstCustomers.EOF
lngTotal = lngTotal + rstCustomers("Quantity")
rstCustomers.MoveNext
Loop
Me.TextBoxTotal = lngTotal
____________________________ multi-tasking - the ability to hang more than one app. at the same time.
Re: How can I get the total of searched result in Datagrid?
Hi GeoffS,
Really it works nicely. Thanks a lot.
One more querry I have and hope you will help me.
rs.Open "Select [Date], Debit, Credit, (Select Sum (Debit-Credit),From Accounts b Where b.[Date]>=a.[Date] From Accounts a Order By a.[Date]", db, adOpenDynamic, adLockOptimistic
Actually I need the above code for the following attached project.
GeoffS Level: VB Lord Registered: 29-09-2004 Posts: 536
Re: How can I get the total of searched result in Datagrid?
Hi Sneha,
I couldn't open your zip file, it seems to be corrupted, so I am guessing that what you are asking is for the SQL Query to be re-written from T-SQL to standard SQL. If so then I would first make the observation that to name a database field "Date" is not a good idea, any Field name that can be interpreted as an inbuilt Function or a "Keyword" should really be avoided so as to save confusion - if those square brackets get omitted by mistake then you are going to get problems. I would suggest either prefixing it with the data type ("dteDate") or if you want to keep it more readable maybe "transaction_date".
Can you try posting your zip file again so that I can see what you need.
____________________________ multi-tasking - the ability to hang more than one app. at the same time.
29-03-2006 at 09:42 AM
|
Goran Level: Moderator Registered: 16-05-2002 Posts: 1681
Re: How can I get the total of searched result in Datagrid?
"Select [Date], Debit, Credit, (Select Sum (Debit-Credit) From Accounts b Where b.[Date]>=a.[Date]) From Accounts a Order By a.[Date]"
____________________________
If you find the answer helpful, please mark this topic as solved.