Can someone help me with this, please.
What i want to do is find all the records that have the same category, than add the time spent on that category, than spit out the next category. I have this, but when it lists the records, it does not add them together, the ones that are the same, it just lists them all.
What is does now:
Category Moves 60 hrs
Category Moves 30 Hrs
Category Email 45 Hrs
Category Email 60 Hrs
What I want is this:
Category Moves 90 Hrs
Category Email 105 Hrs
Here is what i got so far:
SQL Statement is based on week # and User ID.
<%
UserID = TRIM( Request.QueryString( "UserID"
)
WkID = TRIM( Request.QueryString( "WkID"
)
Set RS = Server.CreateObject("ADODB.Recordset"
SqlString = "SELECT Main.Site, Main.Technician, Main.TSpent, Main.Category, Main.Date1, Main.Department, Main.DeptWork, Main.Week, Department.Department as Department_Name, Technicians.Technician as Tech_Name, Category.Category as Category_Name "
SqlString = SqlString & " FROM ((((Main INNER JOIN Technicians ON Main.Technician = Technicians.TechID) INNER JOIN Site ON Main.Site = Site.SiteID) INNER JOIN Department ON Main.Department = Department.DeptID) INNER JOIN Category ON Main.Category = Category.CatID) INNER JOIN Week ON Main.Week = Week.WeekID"
SqlString = SqlString & " WHERE Technicians.TechID = " & UserID & " and Week.WeekID = " & WkID
SET RS = objConn.Execute( sqlString )
%>
The actual output:
<%
While Not RS.EOF
OldCatName = RS("Category"
Spent = RS("TSpent"
Total = 0
%>
<table width="100%" border="1" cellpadding="0" cellspacing="2" bordercolor="#000000" class="Listing">
<!--DWLayoutTable-->
<tr>
<td width="204" bgcolor="<%=bgColor%>"><div align="left"><em>Category</em></div></td>
<td width="487" bgcolor="<%=bgColor%>"><div align="center"><em><font color="#000000" size="2"><strong><%=RS("Category_Name"
%></strong>
</font></em></div></td>
<td width="287" bgcolor="<%=bgColor%>"><div align="right"><em><font color="#000000" size="2">
<%
IF Not RS.EOF then 'IF THERE IS STILL SOMETHING IN THE RECORDSET
compstr = StrComp(RS("Category"
,OldCatName,1) ' COMPARE Categories
If compstr = 0 then 'IF THE UNIT NAMES MATCH
Total = Spent + Total
RS.MoveNext
else
OldCatName = RS("Category"
end if
end if
%>
<%Response.Write Total %> Hr(s)</font></em></div></td>
</tr>
</table>
<tr>
<td width="15%" nowrap>
<div align="RIGHT"></div></td>
<td width="5%">
<div align="CENTER"> </div></td>
</tr>
<%
'ALLOWS SHOWING OF NEXT RECORD IF UNIT DOES NOT HAVE ANY MORE VALUES.
IF Not RS.EOF then
compstr = StrComp(RS("Category"
,OldCatName,1)
If compstr <> 0 then
OldCatName = RS("Category"
end if
end if
Wend
%>
Any help I would aprpeciate it very much.
What i want to do is find all the records that have the same category, than add the time spent on that category, than spit out the next category. I have this, but when it lists the records, it does not add them together, the ones that are the same, it just lists them all.
What is does now:
Category Moves 60 hrs
Category Moves 30 Hrs
Category Email 45 Hrs
Category Email 60 Hrs
What I want is this:
Category Moves 90 Hrs
Category Email 105 Hrs
Here is what i got so far:
SQL Statement is based on week # and User ID.
<%
UserID = TRIM( Request.QueryString( "UserID"
WkID = TRIM( Request.QueryString( "WkID"
Set RS = Server.CreateObject("ADODB.Recordset"
SqlString = "SELECT Main.Site, Main.Technician, Main.TSpent, Main.Category, Main.Date1, Main.Department, Main.DeptWork, Main.Week, Department.Department as Department_Name, Technicians.Technician as Tech_Name, Category.Category as Category_Name "
SqlString = SqlString & " FROM ((((Main INNER JOIN Technicians ON Main.Technician = Technicians.TechID) INNER JOIN Site ON Main.Site = Site.SiteID) INNER JOIN Department ON Main.Department = Department.DeptID) INNER JOIN Category ON Main.Category = Category.CatID) INNER JOIN Week ON Main.Week = Week.WeekID"
SqlString = SqlString & " WHERE Technicians.TechID = " & UserID & " and Week.WeekID = " & WkID
SET RS = objConn.Execute( sqlString )
%>
The actual output:
<%
While Not RS.EOF
OldCatName = RS("Category"
Spent = RS("TSpent"
Total = 0
%>
<table width="100%" border="1" cellpadding="0" cellspacing="2" bordercolor="#000000" class="Listing">
<!--DWLayoutTable-->
<tr>
<td width="204" bgcolor="<%=bgColor%>"><div align="left"><em>Category</em></div></td>
<td width="487" bgcolor="<%=bgColor%>"><div align="center"><em><font color="#000000" size="2"><strong><%=RS("Category_Name"
</font></em></div></td>
<td width="287" bgcolor="<%=bgColor%>"><div align="right"><em><font color="#000000" size="2">
<%
IF Not RS.EOF then 'IF THERE IS STILL SOMETHING IN THE RECORDSET
compstr = StrComp(RS("Category"
If compstr = 0 then 'IF THE UNIT NAMES MATCH
Total = Spent + Total
RS.MoveNext
else
OldCatName = RS("Category"
end if
end if
%>
<%Response.Write Total %> Hr(s)</font></em></div></td>
</tr>
</table>
<tr>
<td width="15%" nowrap>
<div align="RIGHT"></div></td>
<td width="5%">
<div align="CENTER"> </div></td>
</tr>
<%
'ALLOWS SHOWING OF NEXT RECORD IF UNIT DOES NOT HAVE ANY MORE VALUES.
IF Not RS.EOF then
compstr = StrComp(RS("Category"
If compstr <> 0 then
OldCatName = RS("Category"
end if
end if
Wend
%>
Any help I would aprpeciate it very much.