473,804 Members | 4,181 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(StrDu p(80, "-") & vbCrLf)
sb.Append("Sub Total: " & SubTotal & vbCrLf)
sb.Append(StrDu p(80, "-") & vbCrLf)
SubTotal = 0
sb.Append(dr.Ge tString(0).PadR ight(15) _
& dr.GetString(1) .PadRight(15) _
& dr.GetInt32(2). ToString.PadRig ht(15) _
& dr.GetString(3) .PadRight(15) & dr.GetString(4) & vbCrLf)
Else
SubTotal = SubTotal + dr.GetInt32(2)
sb.Append(dr.Ge tString(0).PadR ight(15) _
& dr.GetString(1) .PadRight(15) _
& dr.GetInt32(2). ToString.PadRig ht(15) _
& dr.GetString(3) .PadRight(15) & dr.GetString(4) & vbCrLf)
End If
End While

Aug 12 '07 #1
0 1531

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

Similar topics

2
9429
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 Field 3 below (I really have 21 columns). Also I must show one blank row after each resulting group: Field1 Field2 Field3 Field4 entry1 data2.1 100 data4.1 entry2 data2.2 400 data4.2
1
5203
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 figure out is a grand total at the end of the entire report! Any suggestions? Thanks.
0
1517
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 the bottom. I'd like to add quarterly subtotals in the MIDDLE of the grid on their own rows. The data is sorted by default by date, so after the last March record, I want to insert a subtotal. Which event (ItemDataBound or ItemCreated) is the...
2
4375
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
3499
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 the subtotals appear (possibly in an unused column for each "category" when the category "breaks". Basically I would like to meld the query: select category, sum(amount) from checks group by category order by
9
3648
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 beginner and do not know VB.NET well, let alone how to convert asp.net to vb!! thanks very much --
3
4389
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 a little guidance on how I could get a subtotal for each employee and then total all of the subtotals? I would like to list employee 1's time and total it, then employee 2's time and total it and so on. Then total all of the subtotals. Not sure...
8
2529
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
3808
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 gridview based on column value "Type". I am using VB.NET. Thanks. -- Hutty
0
9706
marktang
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...
0
9579
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10575
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, 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...
0
10330
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10076
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7616
isladogs
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...
0
5520
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3816
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.