Quantcast
Channel: Classic ASP
Viewing all articles
Browse latest Browse all 488

Total Items in a Group

$
0
0

I've got a group working (from some code I found on Stack Exchange) and it does what I need so far.  However, I'd like to have subtotals for the items for each group.  Here is my chunk of code:

strSQL2 = "SELECT ts_TimeSheetItems.[WorkOrderID], ts_TimeSheetItems.[DayDate], ts_TimeSheetItems.[Type], ts_TimeSheetItems.[Duty], ts_TimeSheetItems.[TimeWorked], ts_TimeSheetItems.[TaskPerformed] FROM ts_TimeSheetItems WHERE TimeHeaderID=5012 ORDER BY DayDate ASC;"

rsBob.Open strSQL2, conn

Dim currentGroupName, previousGroupName, One
currentGroupName = ""
previousGroupName = ""
Do Until rsBob.EOF
    currentGroupName = rsBob("DayDate")
    One = rsBob("TimeWorked")
    'Two = rsBob("TimeWorked")
    If currentGroupName<>previousGroupName Then
        Response.Write("<P>")
        Response.Write("<B>" & currentGroupName & "</B>")
        Response.Write("<BR>")
    End If
    Response.Write(rsBob("TaskPerformed") & " " & One & "<BR>")
   'SOMEHOW I NEED TO GET A SUBTOTAL HERE???
  previousGroupName = currentGroupName
    rsBob.MoveNext
Loop
rsBob.Close

Here is the output:

9/16/15
Accounting 1
Babysitting 2.5
Lawn Mowing 3.0

9/17/15
Lawn Mowing 2.5
Free Time 0.5
Trimming 4

It will look nicer in a table but while I'm still hacking I usually forego formatting.  Anyway, I'm trying to figure out how to get the subtotal for each group (and a grand total would be nice too!)

I can't seem to get a Sum of each group to work (not shown here because none of my attempts have worked).  I am not at all familiar with asp, but used to dabble in javascript, perl, etc.  BTW, not having semi-colons at the ends of lines is send my OCD into overdrive Tongue Out

Any help would be greatly appreciated.  I'd like to do it in asp, but was thinking about populating a javascript variable with hours somehow and using that to handle the math if I have to. I figure that if "One" holds the number of hours and can be displayed in html then there has got to be a way I can get the sum or plug it into another variable.


Viewing all articles
Browse latest Browse all 488

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>