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. -
-
<TR BGCOLOR="CEEFFF">
-
<TD> <DIV ALIGN="CENTER">RECORD</DIV></TD>
-
<TD> <DIV ALIGN="CENTER"><STRONG>INDIVIDUAL</STRONG></DIV></TD>
-
<TD> <DIV ALIGN="CENTER"><STRONG>COMPLETE DATE</STRONG></DIV></TD>
-
</TR>
-
-
-
<%
-
-
WHILE NOT RS.EOF
-
-
Response.Write("<TR>")
-
Response.Write("<TD>" & RS("RecordID") & " </TD>")
-
Response.Write("<TD>" & RS("Individual") & " </TD>")
-
Response.Write("<TD>" & RS("CompleteDate") & " </TD>")
-
-
-
Response.Write("</TR>")
-
-
strCount=strCount + 1
-
-
RS.MoveNext
-
Wend
-
-
RS.Close
-
Conn.Close
-
set Conn = nothing
-
set RS = Nothing
-
-
Response.Write("<FONT FACE=""HELVETICA,HELV,ARIAL"" COLOR=""#000000"" SIZE=""2"">Total Records: ")
-
Response.Write("</FONT>")
-
Response.Write("<FONT FACE=""HELVETICA,HELV,ARIAL"" COLOR=""#FF0000"" SIZE=""2"">")
-
Response.Write(strCount)
-
-
%>
-
-
19 3116 jeffstl 432
Recognized Expert Contributor
So did it work for you?
I did not see you post an actual question or problem you had.
I will point out that rather then loop through all your records you can get a total immediately from just using an SQL query. http://www.w3schools.com/sql/func_count_ast.asp
Hi Jeff,
I got the total records count for ALL individual show up correctly. What I want to do is to get a total count for EACH individual. Please see below and thanks for your help. Current:
CroCrew
CroCrew
Jim
Jim
Total Records: 4 Want it to be:
CroCrew
....
....
Total = 2
Jim
....
....
Total = 2
Hi Hotflash,
Jeff is right about getting the sql query to do the work for you. In order to get a count of each individual you can use the following simple query:
SELECT Individual, COUNT(CompleteD ate) AS RecordCount FROM MyTable Group By Individual
If you want to put a condition in here then you can do so like this:
SELECT Individual, COUNT(CompleteD ate) AS RecordCount FROM MyTable WHERE CompleteDate IS NOT NULL Group By Individual
Use this in your sql string then cycle through each of the records as you would before: - While Not RS.eof
-
Response.Write("<tr>")
-
Response.Write("<td>" & RS("Individual") & " </td>")
-
Response.Write("<td>" & RS("RecordCount ") & " </td>")
-
Response.Write("</tr>")
-
RS.MoveNext
-
WEnd
-
Let us know how you get on,
Dr B
PS This sounds silly I know but you should keep all your html as lower case - although it won't affect you at the moment if you ever start using .NET you'll find your html won't validate because it's in uppercase. Just thought I'd let you know ;-)
Hi Jeff,
I got the total records count for ALL individual show up correctly. What I want to do is to get a total count for EACH individual. Please see below and thanks for your help. Current:
CroCrew
CroCrew
Jim
Jim
Total Records: 4 Want it to be:
CroCrew
....
....
Total = 2
Jim
....
....
Total = 2
Hi hotfalsh
Try this sql query in select statement - SELECT YourColumn,yourcolumn, COUNT(*) TotalCount
-
FROM YourTable
-
GROUP BY YourColumn
-
ORDER BY COUNT(*) ASC
thanks
Hi idsanjeev and DrBunchman,
Your recommendations sound EXTREMELY GOOD however, I am having problem to try to integrate them into the actual code that I used because I have case statements, etc for different type of search as well.
Is there a way, I can send you the 2 files that I used (1 search option, 1 display search result) for your recommendations ? Please advise or send me a PM message. Thanks once again for your outstanding support.
Hi idsanjeev and DrBunchman,
Your recommendations sound EXTREMELY GOOD however, I am having problem to try to integrate them into the actual code that I used because I have case statements, etc for different type of search as well.
Is there a way, I can send you the 2 files that I used (1 search option, 1 display search result) for your recommendations ? Please advise or send me a PM message. Thanks once again for your outstanding support.
Hi Hotflash, have you managed to fix this yet or has idsanjeev helped you out?
Hi Hotflash
you can simply attached your file in post or pm
Hi Sanjeev,
Below are the files that I used for this search and display reports accordingly.
The MS Access fields are defined as follows:
RecordID: AutoNumber and Primary Key
CompleteDate: Date/Time
ProjectType: Text
Network: Text
Individual: Text (First and Last Name)
Thanks once again for your outstanding support. -
-
<HTML>
-
<HEAD>
-
<TITLE>Homepage</TITLE>
-
-
<STYLE>
-
table.MAIN { border: none; }
-
table.MAIN TR TD { font-size: 14px; font-family: helvetica, helv, arial; }
-
table.MAIN TR TH { font-size: 14px; font-family: helvetica, helv, arial; font-weight: bold;
-
width: 350px; text-align: right; }
-
</STYLE>
-
-
<SCRIPT>
-
var msgs = new Array("",
-
"Enter Individual Name (Full or Partial Name):",
-
"Enter Project Type (Full or Partial):",
-
"Enter Network (Full or Partial):",
-
"Enter Region (Full or Partial):");
-
-
function setInfo( )
-
{
-
var sts = document.xForm.SearchType;
-
-
// set message according to searchtype:
-
for ( var n = 0; n < sts.length; ++n )
-
{
-
if ( sts[n].checked ) document.getElementById("SLABEL").innerHTML = msgs[n];
-
}
-
document.getElementById("SBOX").style.visibility = sts[0].checked ? "hidden" : "visible";
-
}
-
</SCRIPT>
-
-
</HEAD>
-
-
<BODY ONLOAD="jsClock()" BGCOLOR="#FFFFFF">
-
<BR>
-
-
<TABLE CLASS="MAIN" CELLSPACING="0" CELLPADDING="4" C>
-
-
<DIV ALIGN ="LEFT">
-
-
<FORM ID="xForm" NAME="xForm" METHOD="post" ACTION="DisplayReports-Test.asp">
-
-
<SCRIPT LANGUAGE="JavaScript" ID="jscal1xx">
-
var cal1xx = new CalendarPopup("testdiv1");
-
cal1xx.showNavigationDropdowns();
-
</SCRIPT>
-
<SCRIPT LANGUAGE="JavaScript">writeSource("jscal1xx");</SCRIPT>
-
-
<SCRIPT LANGUAGE="JavaScript" ID="jscal2xx">
-
var cal2xx = new CalendarPopup("testdiv2");
-
cal2xx.showNavigationDropdowns();
-
</SCRIPT>
-
<SCRIPT LANGUAGE="JavaScript">writeSource("jscal2xx");</SCRIPT>
-
<P></P>
-
-
<TR>
-
<TH ALIGN="right" VALIGN="top"><FONT FACE="HELVETICA,HELV,ARIAL" SIZE="2">Type of Search: </FONT></TH>
-
<TD>
-
<FONT FACE="HELVETICA,HELV,ARIAL" SIZE="2"><INPUT TYPE="radio" NAME="SearchType" VALUE="0" onClick="setInfo()"> All Completed Records <BR/> </FONT>
-
<FONT FACE="HELVETICA,HELV,ARIAL" SIZE="2"><INPUT TYPE="radio" NAME="SearchType" VALUE="1" onClick="setInfo()"> By Individual <BR/> </FONT>
-
<FONT FACE="HELVETICA,HELV,ARIAL" SIZE="2"><INPUT TYPE="radio" NAME="SearchType" VALUE="2" onClick="setInfo()"> By Project Type <BR/> </FONT>
-
<FONT FACE="HELVETICA,HELV,ARIAL" SIZE="2"><INPUT TYPE="radio" NAME="SearchType" VALUE="3" onClick="setInfo()"> By Network <BR/> </FONT>
-
<FONT FACE="HELVETICA,HELV,ARIAL" SIZE="2"><INPUT TYPE="radio" NAME="SearchType" VALUE="4" onClick="setInfo()"> By Region <BR/> </FONT>
-
</TD>
-
</TR>
-
-
<TR>
-
<TH VALIGN="top" ID="SLABEL"></TH>
-
<TD ID="SBOX" STYLE="visibility: hidden;"><FONT FACE="HELVETICA,HELV,ARIAL" SIZE="2">
-
<INPUT NAME="SearchWith" Size="40"></FONT>
-
</TD>
-
</TR>
-
-
<TR>
-
<TH ALIGN="right" VALIGN="top"><FONT FACE="HELVETICA,HELV,ARIAL" SIZE="2">Enter Dates </FONT></TH>
-
<TD>
-
<FONT FACE="HELVETICA,HELV,ARIAL" SIZE="2"> From </FONT>
-
<INPUT ID="FDates" NAME="FDates" Size="9">
-
-
<FONT FACE="HELVETICA,HELV,ARIAL" SIZE="2"> To </FONT>
-
<INPUT ID="TDates" NAME="TDates" Size="9">
-
</TD>
-
</TR>
-
-
<TR>
-
<TD></TD>
-
<TD><INPUT CLASS="Table_Blue" TYPE="submit" NAME="Submit" VALUE="SEARCH YOUR REPORT"></TD>
-
</TR>
-
</TABLE>
-
</FORM>
-
-
<CENTER>
-
<FONT FACE="HELVETICA,HELV,ARIAL" COLOR="#FF0000" SIZE="2">
-
<%
-
If Request.QueryString("error") <> "" Then
-
Response.Write(Request.QueryString("error"))
-
End If
-
%>
-
</FONT>
-
</CENTER>
-
-
</BODY>
-
</HTML>
-
-
-
<%
-
strSearchType = trim(Request("SearchType"))
-
strFDates = trim(Request("FDates"))
-
strTDates = trim(Request("TDates"))
-
If Not IsNumeric(strSearchType) Then sType = 0 Else sType = CDBL(strSearchType)
-
-
strSearchWith = trim(Request("SearchWith"))
-
sqlSearchWith = "'%" & Replace(strSearchWith,"'","''") & "%'"
-
-
FDate = "NO"
-
TDate = "NO"
-
On Error Resume Next
-
FDate = DateValue( CDate( Request("FDates") ) )
-
TDate = DateValue( CDate( Request("TDates") ) )
-
On Error GoTo 0
-
-
If strFDates = "" OR _
-
strTDates = "" Then
-
Response.Redirect("SearchReports-Test.asp?error=Please+enter+all+the+required+fields+before+searching. Thanks.")
-
-
Else
-
Set Conn = Server.CreateObject("ADODB.Connection")
-
Set RS = Server.CreateObject("ADODB.RecordSet")
-
-
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("Database.mdb") _
-
& "; Jet OLEDB:Database Password=happy"
-
-
select case sType
-
case 0 : where = " WHERE 1=1 "
-
case 1 : where = " WHERE Individual LIKE " & sqlSearchWith
-
case 2 : where = " WHERE ProjectType LIKE " & sqlSearchWith
-
case 3 : where = " WHERE Network LIKE " & sqlSearchWith
-
case 4 : where = " WHERE Region LIKE " & sqlSearchWith
-
case else
-
Response.Redirect ("SearchReports-Test.asp?error=Sorry+...+Please+enter+a+valid+search+type.")
-
end select
-
-
strSQL = "SELECT * FROM TableProjects " & where
-
-
If FDate <> "NO" AND TDate <> "NO" Then
-
strSQL = strSQL & " AND CompleteDate BETWEEN #" & FDate & "# AND #" & TDate & "#"
-
End If
-
-
strSQL = strSQL & " ORDER BY Individual, RecordID"
-
-
RS.Open strSQL, Conn
-
-
If (RS.EOF) Then
-
Response.Redirect ("SearchReports-Test.asp?error=Sorry+...+Report+does+not+exist. +Please+enter+a+valid+search+type.+ Thanks.")
-
End If
-
End If
-
%>
-
-
<HTML>
-
<HEAD>
-
<TITLE>Homepage</TITLE>
-
-
-
</HEAD>
-
-
<BODY ONLOAD="jsClock()" BGCOLOR="#FFFFFF">
-
-
<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0">
-
-
<DIV ALIGN="LEFT">
-
-
<TABLE WIDTH="100%"BORDER="1" CELLSPACING="0" CELLPADDING="1">
-
<TR BGCOLOR="CEEFFF">
-
<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>
-
<TD WIDTH="15%" CLASS="Table_Black"> <DIV ALIGN="CENTER"><FONT FACE=""HELVETICA,HELV,ARIAL"" COLOR=""#000000"" SIZE=""1""><STRONG>INDIVIDUAL</STRONG></DIV></FONT></TD>
-
<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>
-
<TD WIDTH="15%" CLASS="Table_Black"> <DIV ALIGN="CENTER"><FONT FACE=""HELVETICA,HELV,ARIAL"" COLOR=""#000000"" SIZE=""1""><STRONG>NETWORK</STRONG></DIV></FONT></TD>
-
<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>
-
<TD WIDTH="25%" CLASS="Table_Black"> <DIV ALIGN="CENTER"><FONT FACE=""HELVETICA,HELV,ARIAL"" COLOR=""#000000"" SIZE=""1""><STRONG>REGION</STRONG></DIV></FONT></TD>
-
</TR>
-
-
<CENTER>
-
<%
-
-
WHILE NOT RS.EOF
-
-
Response.Write("<TR>")
-
Response.Write("<TD><FONT FACE=""HELVETICA,HELV,ARIAL"" COLOR=""#000000"" SIZE=""2"">" & RS("RecordID") & " </FONT></TD>")
-
Response.Write("<TD><FONT FACE=""HELVETICA,HELV,ARIAL"" COLOR=""#000000"" SIZE=""2"">" & RS("Individual") & " </FONT></TD>")
-
Response.Write("<TD><FONT FACE=""HELVETICA,HELV,ARIAL"" COLOR=""#000000"" SIZE=""2"">" & RS("CompleteDate") & " </FONT></TD>")
-
Response.Write("<TD><FONT FACE=""HELVETICA,HELV,ARIAL"" COLOR=""#000000"" SIZE=""2"">" & RS("Network") & " </FONT></TD>")
-
Response.Write("<TD><FONT FACE=""HELVETICA,HELV,ARIAL"" COLOR=""#000000"" SIZE=""2"">" & RS("ProjectType") & " </FONT></TD>")
-
Response.Write("<TD><FONT FACE=""HELVETICA,HELV,ARIAL"" COLOR=""#000000"" SIZE=""2"">" & RS("Region") & " </FONT></TD>")
-
-
Response.Write("</TR>")
-
-
strCount=strCount + 1
-
-
RS.MoveNext
-
Wend
-
-
RS.Close
-
Conn.Close
-
set Conn = nothing
-
set RS = Nothing
-
%>
-
</CENTER>
-
</TABLE>
-
<BR>
-
<%
-
Response.Write("<FONT FACE=""HELVETICA,HELV,ARIAL"" COLOR=""#000000"" SIZE=""2"">Total Records: ")
-
Response.Write("</FONT>")
-
Response.Write("<FONT FACE=""HELVETICA,HELV,ARIAL"" COLOR=""#FF0000"" SIZE=""2"">")
-
Response.Write(strCount)
-
Response.Write("</FONT>")
-
%>
-
</DIV>
-
-
</BODY>
-
</HTML>
-
Hi hotflash
i think you have to change your code for count individually.
But Dr. B can help you out if is possible to count individually with your code.
i havn't any idea but i try to think if is possible.
regards
jha
Sign in to post your reply or Sign up for a free account.
Similar topics |
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.
|
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
|
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"
|
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
|
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")
| |
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...
|
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
|
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,...
|
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...
|
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...
|
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...
| |
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...
|
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,...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |