472,365 Members | 1,329 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Subtotals


I'm using VB .NET and I'm trying to "roll my own" report subtotals. I'm
building a string from a datareader top pass to a reporting class and I want
to break and subtotal QTY at each change in shipper and I have struggled
with the code to do so for days and just can't seem to get it. I can get it
to insert a draw a line at a shipper change, but I can't get the subtotals.
The actual Code is down below data sample. I appreciate any advice I can
receive.
Paul
SHIP PART QTY
----------------------------------------------------
01082153 54472 180
01082155 54472 40
01082156 51166 8
01082156 51167 16
01082156 51168 8
01082156 51169 184
01082156 53442 8
01082157 51167 16
01082157 51168 8
01082157 51169 192
01082157 53442 8
01082158 51167 24
01082158 51168 8
01082158 51169 184
01082158 53442 8
01082159 50120 15
01082159 54827 90
01082159 54829 15
01082159 54830 225
01082160 54827 90

'code
While dr.Read
If iCounter = 0 Then
FirstPass = dr.GetString(0)
iCounter = CShort(iCounter + 1)
End If

iTotal = iTotal + dr.GetInt32(2)
CurrentPass = dr.GetString(0)

If CurrentPass <FirstPass Then

FirstPass = CurrentPass
sb.Append(StrDup(80, "-") & vbCrLf)
sb.Append("Sub Total: " & SubTotal & vbCrLf)
sb.Append(StrDup(80, "-") & vbCrLf)
SubTotal = 0
sb.Append(dr.GetString(0).PadRight(15) _
& dr.GetString(1).PadRight(15) _
& dr.GetInt32(2).ToString.PadRight(15) _
& dr.GetString(3).PadRight(15) & dr.GetString(4) & vbCrLf)
Else
SubTotal = SubTotal + dr.GetInt32(2)
sb.Append(dr.GetString(0).PadRight(15) _
& dr.GetString(1).PadRight(15) _
& dr.GetInt32(2).ToString.PadRight(15) _
& dr.GetString(3).PadRight(15) & dr.GetString(4) & vbCrLf)
End If
End While

Aug 12 '07 #1
0 1469

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Scott | last post by:
How can you show SUBTOTALS in the same column as the data, NOT in a separate column? I need to SUBTOTAL in the same column as one of the the data columns, like the subtotals 700 and 800 under...
1
by: Andy V | last post by:
Hi. I've got a multi page report of my monthly purchases. I'd like a running total (month to date) at the end of each page and to have that total at the top of the following page. So far all I can...
0
by: Mark | last post by:
Is there a way to put a subtotal in a datagrid? For example, let's say I have a datagrid of sales for a given year. No paging. I've used the ItemDataBound event of the datagrid to add totals at...
2
by: Richard Grene | last post by:
I am creating an Excel spreadsheet using a query function in my vb code. This works fine. I can format the columns but dont know how to create subtotals and a grand total. Thanks, Richard
4
by: Jerry LeVan | last post by:
Is is possible, via some clever sql coding ( perhaps with PL/pgsql) to get subtotals to appear in a selection, ie If I have a query: select * from checks order by category I would like the have...
9
by: latin & geek via DotNetMonster.com | last post by:
hi. ive been searching high and low for help with how to show subtotals for each column in a datagrid. so far ive only seen help for asp.net or c#..... can someone please help for VB.NET? im a...
3
by: Greg | last post by:
I have a database that tracks the vacation time of each employee of the company that I work for. Everything works great and totals all of the vacation time that has been used. Could someone give me...
8
by: xian2 | last post by:
Hi, I have two subreports on my report and they both have a subtotal in the subreport footer section. I have managed to work out how to call the subtotals in to the main form: =!!.. =!!..
2
by: =?Utf-8?B?SHV0dHk=?= | last post by:
I have searched the net but have been unable to find a solution to subtotaling in a gridview. I have a gridview that is bounded to sqldatasource where I would like to subtotal rows throughout the...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.

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.