473,805 Members | 2,074 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Total Record Count per Individual

85 New Member
Hi CroCrew et. All,

I am currently working on a quick report that count a total of completed records per Individual. The code that I have will add up all Individual completed records and what I want is to get a total for each of the Individuals per month. For example,

CroCrew
....
....
Total = 2

Jim
....
....
Total = 2

Below is part of the show completed records that I used and wonder if you can help. This is my first time to try to put the code into the format that you and HOPE YOU IT WILL SHOW UP RIGHT. Thanks once again for your help.

Expand|Select|Wrap|Line Numbers
  1.  
  2. <TR BGCOLOR="CEEFFF">
  3.     <TD> <DIV ALIGN="CENTER">RECORD</DIV></TD>
  4.     <TD> <DIV ALIGN="CENTER"><STRONG>INDIVIDUAL</STRONG></DIV></TD>
  5.     <TD> <DIV ALIGN="CENTER"><STRONG>COMPLETE DATE</STRONG></DIV></TD>
  6.   </TR>
  7.  
  8.  
  9. <%
  10.  
  11. WHILE NOT RS.EOF 
  12.  
  13. Response.Write("<TR>")
  14. Response.Write("<TD>" & RS("RecordID") & "&nbsp;</TD>")
  15. Response.Write("<TD>" & RS("Individual") & "&nbsp;</TD>")
  16. Response.Write("<TD>" & RS("CompleteDate") & "&nbsp;</TD>")
  17.  
  18.  
  19. Response.Write("</TR>")
  20.  
  21. strCount=strCount + 1
  22.  
  23. RS.MoveNext
  24. Wend
  25.  
  26. RS.Close
  27. Conn.Close
  28. set Conn = nothing
  29. set RS = Nothing
  30.  
  31. Response.Write("<FONT FACE=""HELVETICA,HELV,ARIAL"" COLOR=""#000000"" SIZE=""2"">Total Records:   ")
  32.                       Response.Write("</FONT>")
  33.                         Response.Write("<FONT FACE=""HELVETICA,HELV,ARIAL"" COLOR=""#FF0000"" SIZE=""2"">")
  34.                         Response.Write(strCount)
  35.  
  36. %>
  37.  
  38.  
Feb 26 '08
19 3126
hotflash
85 New Member
Thanks for your outstanding support and let me know if you have any luck or not.

Meanwhile, Dr B and CroCrew, any comments? Thanks.
Mar 13 '08 #11
DrBunchman
979 Recognized Expert Contributor
Hi Hotflash,

Sorry for the late reply - I've been on holiday - hopefully you've got it working by now but if not....

Do you mean you want to use a different column in your count depending on which search type the user selects?

This shouldn't cause you any problems once you get started. Just remember that any columns that you Select alongside your Count need to be included in your Group By clause. For example, in the statement below I've selected Col1 and Col2 so I've had to include them in my Group By:

SELECT Col1, Col2, COUNT(Col3) FROM Table1 WHERE Col1 = 'A' GROUP BY Col1, Col2

Keep it simple - build a complete sql statement for each value of sType in your case statement. You can start to make it more efficient once you've got it working.

Looking at your code I can't see you attempting to implement this anywhere - give it a try yourself then come back to us if you have any problems.

Let us know how you get on,

Dr B
Mar 17 '08 #12
hotflash
85 New Member
Hi Dr B (The Expert),

Thanks for your replying and hope you had a good holiday. I have been extremely busy on my daily projects as well. This is something very new to me and just want to do it for experience. Hope you can help me know. I know you can because you are the EXPERT on this stuff. Just want to make sure we are on the same sheet of music here.

Let's say there are 3 people in the team: myself (hotflash), dr b and jha. Each of us here completed 2 projects such as "server install" (this is a type of project or Project Type as listed in the case statement). The current working code, if you select By Project Type, type in "Server Install" in the search box and put in the From and To Dates, it will display the following and it is sorted by Individual.

Individual Project Type
Hotflash Server Install
Hotflash Server Install
Dr B Server Install
Dr B Server Install
Jha Server Install
Jha Server Install

Total Records: 6

Again, the code that I provided you WORK as listed above!

What I want but not knowing what to do is:

Individual Project Type
Hotflash Server Install
Hotflash Server Install

Total Records: 2

Dr B Server Install
Dr B Server Install

Total Records: 2

Jha Server Install
Jha Server Install

Total Records: 2

Grand Total: 6

I have sent Jha the codes for him to look over as well. I think it will be easy for me to send you the codes so you can see the output. I can't seem to integrate what you provided that's why I replied to this forum again to make sure I am not confusing you. As always, you are the best of all best and thanks for your outstanding support.
Mar 18 '08 #13
DrBunchman
979 Recognized Expert Contributor
Hi hotflash, have you got this sorted out yet? If not let me know and I'll take a look at it for you.

Dr B
Mar 25 '08 #14
hotflash
85 New Member
Hi Dr. B,

Haven't tried again lately. Honestly, I am new to the ASP world and this portion is way over my head and would appreciate if you can take a look for me. Please let me know if you can help. Thanks once again for your outstanding support.
Mar 26 '08 #15
deric
92 New Member
Expand|Select|Wrap|Line Numbers
  1. <% 
  2. strSearchType = trim(Request("SearchType")) 
  3. strFDates = trim(Request("FDates")) 
  4. strTDates = trim(Request("TDates")) 
  5. If Not IsNumeric(strSearchType) Then sType = 0 Else sType = CDBL(strSearchType) 
  6.  
  7. strSearchWith = trim(Request("SearchWith")) 
  8. sqlSearchWith = "'%" & Replace(strSearchWith,"'","''") & "%'" 
  9.  
  10. FDate = "NO" 
  11. TDate = "NO" 
  12. On Error Resume Next 
  13.     FDate = DateValue( CDate( Request("FDates") ) ) 
  14.     TDate = DateValue( CDate( Request("TDates") ) ) 
  15. On Error GoTo 0 
  16.  
  17. If strFDates = "" OR _
  18.    strTDates = "" Then
  19. Response.Redirect("SearchReports-Test.asp?error=Please+enter+all+the+required+fields+before+searching. Thanks.")
  20.  
  21. Else
  22. Set Conn = Server.CreateObject("ADODB.Connection") 
  23. Set RS = Server.CreateObject("ADODB.RecordSet") 
  24.  
  25. Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("Database.mdb") _ 
  26.         & "; Jet OLEDB:Database Password=happy" 
  27.  
  28. select case sType 
  29.     case 0 : where = " WHERE 1=1 " 
  30.     case 1 : where = " WHERE Individual LIKE " & sqlSearchWith 
  31.     case 2 : where = " WHERE ProjectType LIKE " & sqlSearchWith 
  32.     case 3 : where = " WHERE Network LIKE " & sqlSearchWith 
  33.     case 4 : where = " WHERE Region LIKE " & sqlSearchWith
  34.     case else 
  35.         Response.Redirect ("SearchReports-Test.asp?error=Sorry+...+Please+enter+a+valid+search+type.")   
  36. end select 
  37.  
  38. strSQL = "SELECT * FROM TableProjects " & where 
  39.  
  40. If FDate <> "NO" AND TDate <> "NO" Then 
  41.     strSQL = strSQL & " AND CompleteDate BETWEEN #" & FDate & "# AND #" & TDate & "#" 
  42. End If 
  43.  
  44. strSQL = strSQL & " ORDER BY Individual, RecordID" 
  45.  
  46. RS.Open strSQL, Conn 
  47.  
  48. If (RS.EOF) Then 
  49.     Response.Redirect ("SearchReports-Test.asp?error=Sorry+...+Report+does+not+exist.  +Please+enter+a+valid+search+type.+  Thanks.") 
  50. End If 
  51. End If
  52. %> 
  53.  
  54. <HTML>
  55. <HEAD>
  56. <TITLE>Homepage</TITLE>
  57.  
  58.  
  59. </HEAD>
  60.  
  61. <BODY ONLOAD="jsClock()" BGCOLOR="#FFFFFF">
  62.  
  63. <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0">
  64.  
  65. <DIV ALIGN="LEFT"> 
  66.  
  67. <TABLE WIDTH="100%"BORDER="1" CELLSPACING="0" CELLPADDING="1">
  68.   <TR BGCOLOR="CEEFFF">
  69.     <TD WIDTH="5%"  CLASS="Table_Black"> <DIV ALIGN="CENTER"><FONT FACE=""HELVETICA,HELV,ARIAL"" COLOR=""#000000"" SIZE=""1""><STRONG>RECORD ID</STRONG></DIV></FONT></TD>
  70.     <TD WIDTH="15%" CLASS="Table_Black"> <DIV ALIGN="CENTER"><FONT FACE=""HELVETICA,HELV,ARIAL"" COLOR=""#000000"" SIZE=""1""><STRONG>INDIVIDUAL</STRONG></DIV></FONT></TD>
  71.     <TD WIDTH="8%" CLASS="Table_Black"> <DIV ALIGN="CENTER"><FONT FACE=""HELVETICA,HELV,ARIAL"" COLOR=""#000000"" SIZE=""1""><STRONG>COMPLETE DATE</STRONG></DIV></FONT></TD>
  72.     <TD WIDTH="15%"  CLASS="Table_Black"> <DIV ALIGN="CENTER"><FONT FACE=""HELVETICA,HELV,ARIAL"" COLOR=""#000000"" SIZE=""1""><STRONG>NETWORK</STRONG></DIV></FONT></TD>
  73.     <TD WIDTH="25%" CLASS="Table_Black"> <DIV ALIGN="CENTER"><FONT FACE=""HELVETICA,HELV,ARIAL"" COLOR=""#000000"" SIZE=""1""><STRONG>PROJECT TYPE</STRONG></DIV></FONT></TD>
  74.     <TD WIDTH="25%" CLASS="Table_Black"> <DIV ALIGN="CENTER"><FONT FACE=""HELVETICA,HELV,ARIAL"" COLOR=""#000000"" SIZE=""1""><STRONG>REGION</STRONG></DIV></FONT></TD>
  75.   </TR>
  76.  
  77. <CENTER>
  78. <%
  79. Dim count As Int
  80. Dim curr, prev As String
  81.  
  82. strCount = 0
  83. prev = ""
  84.  
  85. WHILE NOT RS.EOF 
  86.  
  87. curr = RS("Individual")
  88. If curr = prev Then
  89.   count = count + 1
  90. Else
  91.   count = 1
  92. End If
  93.  
  94. Response.Write("<TR>")
  95. Response.Write("<TD><FONT FACE=""HELVETICA,HELV,ARIAL"" COLOR=""#000000"" SIZE=""2"">" & RS("RecordID") & "&nbsp;</FONT></TD>")
  96. Response.Write("<TD><FONT FACE=""HELVETICA,HELV,ARIAL"" COLOR=""#000000"" SIZE=""2"">" & RS("Individual") & "&nbsp;</FONT></TD>")
  97. Response.Write("<TD><FONT FACE=""HELVETICA,HELV,ARIAL"" COLOR=""#000000"" SIZE=""2"">" & RS("CompleteDate") & "&nbsp;</FONT></TD>")
  98. Response.Write("<TD><FONT FACE=""HELVETICA,HELV,ARIAL"" COLOR=""#000000"" SIZE=""2"">" & RS("Network") & "&nbsp;</FONT></TD>")
  99. Response.Write("<TD><FONT FACE=""HELVETICA,HELV,ARIAL"" COLOR=""#000000"" SIZE=""2"">" & RS("ProjectType") & "&nbsp;</FONT></TD>")
  100. Response.Write("<TD><FONT FACE=""HELVETICA,HELV,ARIAL"" COLOR=""#000000"" SIZE=""2"">" & RS("Region") & "&nbsp;</FONT></TD>")
  101.  
  102. Response.Write("</TR>")
  103.  
  104. strCount=strCount + 1
  105.  
  106. If prev <> "" And curr <> prev Then
  107. Response.Write("<TR>")
  108. Response.Write("<TD COLSPAN=6><FONT FACE=""HELVETICA,HELV,ARIAL"" COLOR=""#000000"" SIZE=""2"">" & count & "&nbsp;</FONT></TD>")
  109. Response.Write("</TR>")
  110. End If
  111. prev = curr
  112.  
  113. RS.MoveNext
  114. Wend
  115.  
  116. RS.Close
  117. Conn.Close
  118. set Conn = nothing
  119. set RS = Nothing
  120. %>
  121. </CENTER>
  122. </TABLE>
  123. <BR>
  124. <%        
  125.                       Response.Write("<FONT FACE=""HELVETICA,HELV,ARIAL"" COLOR=""#000000"" SIZE=""2"">Total Records:   ")
  126.                       Response.Write("</FONT>")
  127.                         Response.Write("<FONT FACE=""HELVETICA,HELV,ARIAL"" COLOR=""#FF0000"" SIZE=""2"">")
  128.                         Response.Write(strCount)
  129.                         Response.Write("</FONT>")
  130. %>
  131. </DIV>
  132.  
  133. </BODY>
  134. </HTML>
  135.  
I am not sure if it will work cause I've not tested it, but you may try the code (in bold text) I inserted in your quoted code above. Let me know what would happen. Good luck..
Mar 26 '08 #16
hotflash
85 New Member
Hi deric,

Thanks for your help. It looks like we are getting close now. This is the output that I got when I ran it. 3 issues. Thanks once again for your outstanding support.

1. The total is ALWAYS 1 instead of 2 because let's say Hotflash completes 2
records, etc.

2. For some reason the user keeps jumping around like Dr B jumps up to
Hotflash, Jha jumps up to Dr B.

3. I redefined Dim Int count
Dim String curr, prev

Got "Expected end of statement" errors by using Dim count As Int
Dim curr, prev As String

Individual Project Type

Hotflash Server Install
Dr B Server Install

1

Dr B Server Install
Jha Server Install

1
Jha Server Install
Jha Server Install

1

Grand Total: 6
Mar 26 '08 #17
deric
92 New Member
Expand|Select|Wrap|Line Numbers
  1. prev = ""
  2. count = 0
  3.  
  4. WHILE NOT RS.EOF
  5.  
  6. curr = RS("Individual")
  7. If prev <> "" And curr <> prev Then
  8.   Response.Write("<TR><TD COLSPAN=6><FONT FACE=""HELVETICA,HELV,ARIAL"" COLOR=""#000000"" SIZE=""2"">" & count & "&nbsp;</FONT></TD></TR>")
  9. End If
  10.  
  11. If curr = prev Then
  12.   count = count + 1
  13. Else
  14.   count = 1
  15. End If
  16.  
  17. Response.Write("<TR>")
  18. Response.Write("<TD><FONT FACE=""HELVETICA,HELV,ARIAL"" COLOR=""#000000"" SIZE=""2"">" & RS("RecordID") & "&nbsp;</FONT></TD>")
  19. Response.Write("<TD><FONT FACE=""HELVETICA,HELV,ARIAL"" COLOR=""#000000"" SIZE=""2"">" & RS("Individual") & "&nbsp;</FONT></TD>")
  20. Response.Write("<TD><FONT FACE=""HELVETICA,HELV,ARIAL"" COLOR=""#000000"" SIZE=""2"">" & RS("CompleteDate") & "&nbsp;</FONT></TD>")
  21. Response.Write("<TD><FONT FACE=""HELVETICA,HELV,ARIAL"" COLOR=""#000000"" SIZE=""2"">" & RS("Network") & "&nbsp;</FONT></TD>")
  22. Response.Write("<TD><FONT FACE=""HELVETICA,HELV,ARIAL"" COLOR=""#000000"" SIZE=""2"">" & RS("ProjectType") & "&nbsp;</FONT></TD>")
  23. Response.Write("<TD><FONT FACE=""HELVETICA,HELV,ARIAL"" COLOR=""#000000"" SIZE=""2"">" & RS("Region") & "&nbsp;</FONT></TD>")
  24. Response.Write("</TR>")
  25.  
  26. strCount=strCount + 1
  27.  
  28. RS.MoveNext
  29.  
  30. prev = curr
  31.  
  32. If RS.EOF Then
  33.   Response.Write("<TR><TD COLSPAN=6><FONT FACE=""HELVETICA,HELV,ARIAL"" COLOR=""#000000"" SIZE=""2"">" & count & "&nbsp;</FONT></TD></TR>")
  34. End If
  35.  
  36. Wend
  37.  
Hi hotflash

Did you try to debug it?
Yeah, I did not guarantee that it will work as expected but the idea was already there, we just have to work around it. :-)

I made a modification on the code (in bold text above), I hope it will help you this time around. ;-) Again, I have not tested it but I have simulated it on a paper just once cause I didn't have enough time.

Regarding the issue (3).. What are you using to execute the program? Try not declaring the variables instead, as you have done with your strCount.
Mar 27 '08 #18
hotflash
85 New Member
Hi deric,

You are truly another HERO of this ASP forum. Everything works perfectly.
Thanks once again for your OUTSTANDING SUPPORT.
Mar 27 '08 #19
deric
92 New Member
Hi deric,

You are truly another HERO of this ASP forum. Everything works perfectly.
Thanks once again for your OUTSTANDING SUPPORT.
Glad it helped you out....
Mar 28 '08 #20

Sign in to post your reply or Sign up for a free account.

Similar topics

6
44119
by: Hari Om | last post by:
Here are the details of my error log files: I execute the command and get following message at console: ---------------------------------------------------------------------- ../sqlldr scott/tiger@common control=/full_path/test.ctl log=/full_path/adhoc/test.log SQL*Loader: Release 9.2.0.1.0 - Production on Tue Sep 2 10:49:27 2003 Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
1
5678
by: Henry Stockbridge | last post by:
Hi, I am doing database documentation and run the procedure below to list the record count for each table in the database. The results in the immediate window only a partial listing of tables. It appears the ones missing are linked (ODBC) tables. Any help you can lend would be appreciated. - Henry
2
6968
by: DC Gringo | last post by:
I have a datagrid control that has paging set up and working. What I would like is a total record count (not just per page) in the header or near the header of the datagrid. Here's my code: <asp:DataGrid AllowCustomPaging="false" AllowPaging="true" AllowSorting="true"
1
3190
by: darrel | last post by:
I'm trying to whip up a fancy repeater control that will put records into a two-column table for me. This is how I envision it working: itemtemplate if record count = odd then write out the TR tag td <record> /td if record count = even then wrote out the /TR tag if record count = odd AND it's the last record, write out an empty TD and
4
3094
by: Peter W Johnson | last post by:
Hi guys, I have a problem with a datagrid record count. Here is the code:- <snip> Public Class frmMerchantDeposit Inherits System.Windows.Forms.Form Dim myconnection As New Odbc.OdbcConnection("DSN=database")
1
3626
by: rsbutterfly16 via AccessMonster.com | last post by:
hi guys i have form with a listbox . The listbox is coming from a query that gets all passengers(column 1 in listbox) and destinations(column 3) . so you have repeting rows of passengers since they could have up to three destinations. Then the user has to select a row in the list box , double click even in my listbox i have to sql query to delete the currect item selected (passenger with destination). this works fine. however i need to put...
3
4403
by: inamul | last post by:
I want to see how many people have registered from Countries and also want to Sum the total Table fields 1. Name, 2. Email 3 Country I use this query to get number of people registered against country SELECT count(*) as COUNT , country as COUNTRY
6
1819
by: neenaprasad | last post by:
I have to take values from two tables with single sql statement. SQl = SELECT MemAccounts.MemberID,COUNT(MemAccounts.MemberID) AS Total, Membership.First_Name, Membership.Last_Name FROM MemAccounts, Membership WHERE MemAccounts.IntroduceeID <> 0 AND Membership.IsAgent = 1 AND MemAccounts.MemberID = Membership.MemberID AND MemAccounts.TransDate BETWEEN '" &x_FromDate& "' AND '" &x_ToDate& "' GROUP BY MemAccounts.MemberID,...
2
2769
by: dmne05974 | last post by:
As a novice in Access i am currently writing a database to track certain financial information for a non-profit organisation. As part of the funding they have to monitor age ranges and ethnic minority, this is done with 4 yes/no fields controlled on a form with Bi-state check boxes (minor, adult, ethnicminor, ethnicadult). The database stores many purchase orders for each person as more money is awarded however each person can only be...
0
9718
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
10363
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...
1
10368
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10107
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...
0
9186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6876
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5544
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
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4327
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.