Recordset "Wk" data pulled from an Access Crosstab Query
RecDate Category GW Mc Xm
3/19/2006 Blank 76
3/19/2006 Printed 0 278 0
Recordset "PvsWk" data pulled from another Access Crosstab Query
RecDate Category GW Mc Xm
3/13/2005 Blank 108 0
3/13/2005 Printed 0 466 0
3/14/2005 Blank 353 0
3/14/2005 Printed 0 1695 0
3/15/2005 Blank 267 0
3/15/2005 Printed 0 1618 0
3/16/2005 Blank 205 0
3/16/2005 Printed 1 1448 0
3/17/2005 Blank 238 0
3/17/2005 Printed 0 1416 0
3/18/2005 Blank 230 0
3/18/2005 Printed 0 1345 0
3/19/2005 Blank 90 0
3/19/2005 Printed 0 585 0
I will have percentage fields to calculate.
Here's an example: 278 (Current Mc) 466 (Pvs Mc)
(278-466)/466= -40.34% Decrease
Here's my code on the ASP:
Code:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Dim Wk
Dim Wk_numRows
Set Wk = Server.CreateObject("ADODB.Recordset")
Wk.ActiveConnection = MM_McPOrderCount_STRING
Wk.Source = "SELECT * FROM qryWeek_Crosstab"
Wk.CursorType = 0
Wk.CursorLocation = 2
Wk.LockType = 1
Wk.Open()
Wk_numRows = 0
%>
<%
Dim PvsWk
Dim PvsWk_numRows
Set PvsWk = Server.CreateObject("ADODB.Recordset")
PvsWk.ActiveConnection = MM_McPOrderCount_STRING
PvsWk.Source = "SELECT * FROM qryPvsWeek_Crosstab"
PvsWk.CursorType = 0
PvsWk.CursorLocation = 2
PvsWk.LockType = 1
PvsWk.Open()
PvsWk_numRows = 0
%>
<%
Dim YTD
Dim YTD_numRows
Set YTD = Server.CreateObject("ADODB.Recordset")
YTD.ActiveConnection = MM_McPOrderCount_STRING
YTD.Source = "SELECT * FROM qry4YTDCrosstab"
YTD.CursorType = 0
YTD.CursorLocation = 2
YTD.LockType = 1
YTD.Open()
YTD_numRows = 0
%>
<%
Dim PvsYTD
Dim PvsYTD_numRows
Set PvsYTD = Server.CreateObject("ADODB.Recordset")
PvsYTD.ActiveConnection = MM_McPOrderCount_STRING
PvsYTD.Source = "SELECT * FROM qry4PvsYTDCrosstab"
PvsYTD.CursorType = 0
PvsYTD.CursorLocation = 2
PvsYTD.LockType = 1
PvsYTD.Open()
PvsYTD_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index
Repeat1__numRows = -1
Repeat1__index = 0
Wk_numRows = Wk_numRows + Repeat1__numRows
%>
<%
Dim Repeat2__numRows
Dim Repeat2__index
Repeat2__numRows = -1
Repeat2__index = 0
YTD_numRows = YTD_numRows + Repeat2__numRows
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p align="center"><strong>Weekly Count Comparison</strong></p>
<table width="750" border="1" cellspacing="0" cellpadding="0">
<tr valign="middle">
<td width="270" valign="top">
<table width="270" border="1" cellspacing="0" cellpadding="0">
<tr>
<td bordercolor="#FFFFFF"> </td>
<td bordercolor="#FFFFFF"> </td>
<td colspan="3"> <div align="center">Cur Year</div></td>
</tr>
<tr bgcolor="#333333">
<td> <div align="center">Date</div></td>
<td> <div align="center">Category</div></td>
<td> <div align="center">GW</div></td>
<td> <div align="center">Mc</div></td>
<td> <div align="center">Xm</div></td>
</tr>
<%
While ((Repeat1__numRows <> 0) AND (NOT Wk.EOF))
%>
<tr>
<td><div align="center"><%=(Wk.Fields.Item("RecDate").Value)%></div></td>
<td><div align="center"><%=(Wk.Fields.Item("Category").Value)%></div></td>
<td><div align="center"><%=(Wk.Fields.Item("GW").Value)%></div></td>
<td><div align="center"><%=(Wk.Fields.Item("Mc").Value)%></div></td>
<td><div align="center"><%=(Wk.Fields.Item("Xm").Value)%></div></td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
Wk.MoveNext()
Wend
%>
<%
While ((Repeat2__numRows <> 0) AND (NOT YTD.EOF))
%>
<tr>
<td><div align="center">YTD</div></td>
<td><div align="center"><%=(YTD.Fields.Item("Category").Value)%></div></td>
<td><div align="center"><%=(YTD.Fields.Item("GW").Value)%></div></td>
<td><div align="center"><%=(YTD.Fields.Item("Mc").Value)%></div></td>
<td><div align="center"><%=(YTD.Fields.Item("Xm").Value)%></div></td>
</tr>
<%
Repeat2__index=Repeat2__index+1
Repeat2__numRows=Repeat2__numRows-1
YTD.MoveNext()
Wend
%>
</table></td>
<td width="210" valign="top">
<table width="210" border="1" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="3"> <div align="center">Pvs Year</div></td>
</tr>
<tr bgcolor="#333333">
<td width="70"><div align="center">GW</div></td>
<td width="70"><div align="center">Mc</div></td>
<td width="70"><div align="center">Xm</div></td>
</tr>
<tr>
<td width="70"><div align="center"><%=(PvsWk.Fields.Item("GW").Value)%></div></td>
<td width="70"><div align="center"><%=(PvsWk.Fields.Item("Mc").Value)%></div></td>
<td width="70"><div align="center"><%=(PvsWk.Fields.Item("Xm").Value)%></div></td>
</tr>
<tr>
<td><div align="center"><%=(PvsYTD.Fields.Item("GW").Value)%></div></td>
<td><div align="center"><%=(PvsYTD.Fields.Item("Mc").Value)%></div></td>
<td><div align="center"><%=(PvsYTD.Fields.Item("Xm").Value)%></div></td>
</tr>
</table>
</td>
<td width="254" valign="top">
<table width="210" border="1" cellspacing="0" cellpadding="0">
<tr>
<td colspan="3"><div align="center">Percentage</div></td>
</tr>
<tr bgcolor="#333333">
<td>
<div align="center">GW</div></td>
<td>
<div align="center">Mc</div></td>
<td>
<div align="center">Xm</div></td>
</tr>
<tr>
<td width="70">
<div align="center"> </div></td>
<td><div align="center">
<input name="textfield" type="text"
value="<%=CDbl((Wk("Mc")))-CDbl(PvsWk("Mc"))/CDbl(PvsWk("Mc"))%>"
size="12">
</div></td>
<td><div align="center"></div></td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
<%
Wk.Close()
Set Wk = Nothing
%>
<%
PvsWk.Close()
Set PvsWk = Nothing
%>
<%
YTD.Close()
Set YTD = Nothing
%>
<%
PvsYTD.Close()
Set PvsYTD = Nothing
%>