467,144 Members | 1,412 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,144 developers. It's quick & easy.

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
  • viewed: 1318
Share:

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Scott | last post: by
1 post views Thread by Andy V | last post: by
reply views Thread by Mark | last post: by
2 posts views Thread by Richard Grene | last post: by
4 posts views Thread by Jerry LeVan | last post: by
9 posts views Thread by latin & geek via DotNetMonster.com | last post: by
3 posts views Thread by Greg | last post: by
2 posts views Thread by =?Utf-8?B?SHV0dHk=?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.