Avatar of JoeStone
JoeStone

asked on 

Front Page SQL summing problem

I have the following FP query, that works when I want to sum only one of the fields. For example wtd. However, when I try to add additional summations, such as mtd. I get an error message.
<form BOTID="0" METHOD="POST" action="LaborcUM.asp">
<input type= hidden  name= fpdbr_0_pagingMove value = "   |&lt;   ">
<table border= "0">
<tr>
<td><b>Project</b></td>
<td>
<input TYPE="TEXT" NAME="Project" VALUE="<%=Server.HtmlEncode(Request("Project"))%>">
<font face="MS Sans Serif">&nbsp;</font></td>
</tr>
<tr>
<td><b>Week Ending</b></td>
<td><nobr>
                  
<% if 0 then %>
<% end if %>
<font color="#FF0000">
<!--"This is the code that populates the drop down list" -->
</font>
<%
fp_sQry="SELECT DISTINCT WED FROM LaborCum"
fp_sDefault=""
fp_sNoRecords="No records returned."
fp_sDataConn="wplrv2"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=False
fp_fMenuFormat=True
fp_sMenuChoice="WED"
fp_sMenuValue="WED"
fp_sColTypes="&WED=135&"
fp_iDisplayCols=1
fp_fCustomQuery=True
BOTID=3
fp_iRegion=BOTID
%>
<select NAME="WED" SIZE="1"><option selected><% = Request.Form("WED") %></option>
<!--#include file="../_fpclass/fpdbrgn1.inc"-->
<option><%=FP_FieldHTML(fp_rs,"WED")%></option>
<!--#include file="../_fpclass/fpdbrgn2.inc"-->
</nobr></td>
</tr>
</table>
<br>
<input TYPE="Submit"></form>


<table width="900" border="1">
<thead>
<tr>
<th ALIGN="LEFT" width= "100">
<p align="center"><b>Week Ending</b></th>

<th ALIGN="LEFT" width= "150"><b>Project</b></th>

<th ALIGN="LEFT" width= "150"><b>Employee Name</b></th>
<th ALIGN="LEFT" width= "100">
<p align="right" width= "100"><b>WTD</b></th>
<th ALIGN="LEFT" width= "100">
<p align="right" width= "100"><b>MTD</b></th>
<th ALIGN="LEFT" width= "100">
<p align="right" width= "100"><b>YTD</b></th>
<th ALIGN="LEFT" width= "100">
<p align="right" width= "100"><b>ITD</b></th>

</tr>
</thead>
<tbody>
            
<% if 0 then %>
<SCRIPT Language="JavaScript">
document.write("<div style='background: yellow; color: black;'>The Database Results component on this page is unable to display database content. The page must have a filename ending in '.asp', and the web must be hosted on a server that supports Active Server Pages.</div>");
</SCRIPT>

<% end if %>
<%
fp_sQry="SELECT * FROM LaborCum WHERE (Project LIKE '::Project::%' AND WED =  '::WED::') ORDER BY ""Employee Name"" ASC,Project ASC,wtd ASC"
fp_sDefault="Project=SR06.000.000000&WED=01/05/2007"
fp_sNoRecords="<tr><td colspan=4 align=""LEFT"" width=""100%"">No records returned.</td></tr>"
fp_sDataConn="wplrv2"
fp_iMaxRecords=0
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice="WED"
fp_sMenuValue="WED"
fp_sColTypes="&ID=3&Employee Name=202&wtd=5&Project=202&WED=135&mtd=5&ytd=5&itd=5&"
fp_iDisplayCols=4
fp_fCustomQuery=False
BOTID=0
fp_iRegion=BOTID
%>
<!--#include file="../_fpclass/fpdbrgn1.inc"-->
<tr>
<td>
<p align="center">
<%=FP_FieldVal(fp_rs,"WED")%></td>
<td>
<%=FP_FieldVal(fp_rs,"Project")%></td>
<td>
<%=FP_FieldVal(fp_rs,"Employee Name")%></td>
<td>
<p align="right">
<%=FormatNumber(FP_FieldVal(fp_rs,"wtd"),1)%></td>

<td>
<p align="right">
<%=FormatNumber(FP_FieldVal(fp_rs,"mtd"),2)%></td>

<td>
<p align="right">
<%=FormatNumber(FP_FieldVal(fp_rs,"ytd"),1)%></td>

<td>
<p align="right">
<%=FormatNumber(FP_FieldVal(fp_rs,"itd"),1)%></td>
</tr>
<!--#include file="../_fpclass/fpdbrgn2.inc"-->
</tbody>
</table>

<form method="POST" action="--WEBBOT-SELF--" style="text-align: left">
<input TYPE="hidden" NAME="VTI-GROUP" VALUE="0">
<table width="600" border="1">
<thead>
<tr>
<th ALIGN="LEFT">
<p><b>Total wtd</b></th>
</tr>
</thead>
<tbody>
<!--#include file="../_fpclass/fpdblib.inc"-->
<% if 0 then %>

<SCRIPT Language="JavaScript">
document.write("<div style='background: yellow; color: black;'>The Database Results component on this page is unable to display database content. The page must have a filename ending in '.asp', and the web must be hosted on a server that supports Active Server Pages.</div>");
</SCRIPT>

<% end if %>
<%
fp_sQry="SELECT *,(SELECT sum(wtd) FROM LaborCum WHERE (Project LIKE '::Project::%'AND WED =  '::WED::')) as [Total wtd] FROM LaborCum WHERE (Project LIKE '::Project::%'AND WED =  '::WED::') ORDER BY wtd ASC "
fp_sDefault="Project=SR06.000.000000&WED=01/05/2007&Project=SR06.000.000000&WED=01/05/2007"
fp_sNoRecords="<tr><td colspan=1 align=""LEFT"" width=""100%"">No records returned.</td></tr>"
fp_sDataConn="wplrv2"
fp_iMaxRecords=1
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice="Total wtd"
fp_sMenuValue="Total wtd"
fp_sColTypes="&Total wtd=5&ID=3&Employee Name=202&wtd=5&Project=202&WED=135&mtd=5&ytd=5&itd=5&"
fp_iDisplayCols=1
fp_fCustomQuery=True
BOTID=2
fp_iRegion=BOTID

fp_sQry="SELECT *,(SELECT sum(wtd) FROM LaborCum WHERE (Project LIKE '::Project::%'AND WED =  '::WED::')) as [Total wtd] FROM LaborCum WHERE (Project LIKE '::Project::%'AND WED =  '::WED::') ORDER BY wtd ASC "
fp_sDefault="Project=SR06.000.000000&WED=01/05/2007&Project=SR06.000.000000&WED=01/05/2007"
fp_sNoRecords="<tr><td colspan=1 align=""LEFT"" width=""100%"">No records returned.</td></tr>"
fp_sDataConn="wplrv2"
fp_iMaxRecords=1
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice="Total wtd"
fp_sMenuValue="Total wtd"
fp_sColTypes="&Total wtd=5&ID=3&Employee Name=202&wtd=5&Project=202&WED=135&mtd=5&ytd=5&itd=5&"
fp_iDisplayCols=1
fp_fCustomQuery=True
BOTID=2
fp_iRegion=BOTID
%>

<!--#include file="../_fpclass/fpdbrgn1.inc"-->
<tr>
<td>
<p align="right">
<%=FormatNumber(FP_FieldVal(fp_rs,"Total wtd"),1)%></td>
<td>
<p align="right">
<%=FormatNumber(FP_FieldVal(fp_rs,"Total wtd"),1)%></td>



</tr>
<!--#include file="../_fpclass/fpdbrgn2.inc"-->
</tbody>
</table>
</div>
Web Development SoftwareMicrosoft ApplicationsMicrosoft Access

Avatar of undefined
Last Comment
JoeStone
Avatar of JoeStone
JoeStone

ASKER

I should have added that the error message I am gettingwhen I try and add another Total xtd to the script: "ADODB.Recordset error '800a0cc1'

Item cannot be found in the collection corresponding to the requested name or ordinal.

/projects/_fpclass/fpdblib.inc, line 48 "
Avatar of JoeStone
JoeStone

ASKER

Let me try this again...
Here's the script  that is getting the error message "ADODB.Recordset error '800a0cc1'

Item cannot be found in the collection corresponding to the requested name or ordinal.

/projects/_fpclass/fpdblib.inc, line 48 "

:
<form BOTID="0" METHOD="POST" action="LaborcUM.asp">
<input type= hidden  name= fpdbr_0_pagingMove value = "   |&lt;   ">
<table border= "0">
<tr>
<td><b>Project</b></td>
<td>
<input TYPE="TEXT" NAME="Project" VALUE="<%=Server.HtmlEncode(Request("Project"))%>">
<font face="MS Sans Serif">&nbsp;</font></td>
</tr>
<tr>
<td><b>Week Ending</b></td>
<td><nobr>
                  
<% if 0 then %>
<% end if %>
<font color="#FF0000">
<!--"This is the code that populates the drop down list" -->
</font>
<%
fp_sQry="SELECT DISTINCT WED FROM LaborCum"
fp_sDefault=""
fp_sNoRecords="No records returned."
fp_sDataConn="wplrv2"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=False
fp_fMenuFormat=True
fp_sMenuChoice="WED"
fp_sMenuValue="WED"
fp_sColTypes="&WED=135&"
fp_iDisplayCols=1
fp_fCustomQuery=True
BOTID=3
fp_iRegion=BOTID
%>
<select NAME="WED" SIZE="1"><option selected><% = Request.Form("WED") %></option>
<!--#include file="../_fpclass/fpdbrgn1.inc"-->
<option><%=FP_FieldHTML(fp_rs,"WED")%></option>
<!--#include file="../_fpclass/fpdbrgn2.inc"-->
</nobr></td>
</tr>
</table>
<br>
<input TYPE="Submit"></form>


<table width="900" border="1">
<thead>
<tr>
<th ALIGN="LEFT" width= "100">
<p align="center"><b>Week Ending</b></th>

<th ALIGN="LEFT" width= "150"><b>Project</b></th>

<th ALIGN="LEFT" width= "150"><b>Employee Name</b></th>
<th ALIGN="LEFT" width= "100">
<p align="right" width= "100"><b>WTD</b></th>
<th ALIGN="LEFT" width= "100">
<p align="right" width= "100"><b>MTD</b></th>
<th ALIGN="LEFT" width= "100">
<p align="right" width= "100"><b>YTD</b></th>
<th ALIGN="LEFT" width= "100">
<p align="right" width= "100"><b>ITD</b></th>

</tr>
</thead>
<tbody>
            
<% if 0 then %>
<SCRIPT Language="JavaScript">
document.write("<div style='background: yellow; color: black;'>The Database Results component on this page is unable to display database content. The page must have a filename ending in '.asp', and the web must be hosted on a server that supports Active Server Pages.</div>");
</SCRIPT>

<% end if %>
<%
fp_sQry="SELECT * FROM LaborCum WHERE (Project LIKE '::Project::%' AND WED =  '::WED::') ORDER BY ""Employee Name"" ASC,Project ASC,wtd ASC"
fp_sDefault="Project=SR06.000.000000&WED=01/05/2007"
fp_sNoRecords="<tr><td colspan=4 align=""LEFT"" width=""100%"">No records returned.</td></tr>"
fp_sDataConn="wplrv2"
fp_iMaxRecords=0
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice="WED"
fp_sMenuValue="WED"
fp_sColTypes="&ID=3&Employee Name=202&wtd=5&Project=202&WED=135&mtd=5&ytd=5&itd=5&"
fp_iDisplayCols=4
fp_fCustomQuery=False
BOTID=0
fp_iRegion=BOTID
%>
<!--#include file="../_fpclass/fpdbrgn1.inc"-->
<tr>
<td>
<p align="center">
<%=FP_FieldVal(fp_rs,"WED")%></td>
<td>
<%=FP_FieldVal(fp_rs,"Project")%></td>
<td>
<%=FP_FieldVal(fp_rs,"Employee Name")%></td>
<td>
<p align="right">
<%=FormatNumber(FP_FieldVal(fp_rs,"wtd"),1)%></td>

<td>
<p align="right">
<%=FormatNumber(FP_FieldVal(fp_rs,"mtd"),2)%></td>

<td>
<p align="right">
<%=FormatNumber(FP_FieldVal(fp_rs,"ytd"),1)%></td>

<td>
<p align="right">
<%=FormatNumber(FP_FieldVal(fp_rs,"itd"),1)%></td>
</tr>
<!--#include file="../_fpclass/fpdbrgn2.inc"-->
</tbody>
</table>

<form method="POST" action="--WEBBOT-SELF--" style="text-align: left">
<input TYPE="hidden" NAME="VTI-GROUP" VALUE="0">
<table width="600" border="1">
<thead>
<tr>
<th ALIGN="LEFT">
<p><b>Total wtd</b></th>
</tr>
</thead>
<tbody>
<!--#include file="../_fpclass/fpdblib.inc"-->
<% if 0 then %>

<SCRIPT Language="JavaScript">
document.write("<div style='background: yellow; color: black;'>The Database Results component on this page is unable to display database content. The page must have a filename ending in '.asp', and the web must be hosted on a server that supports Active Server Pages.</div>");
</SCRIPT>

<% end if %>
<%
fp_sQry="SELECT *,(SELECT sum(wtd) FROM LaborCum WHERE (Project LIKE '::Project::%'AND WED =  '::WED::')) as [Total wtd] FROM LaborCum WHERE (Project LIKE '::Project::%'AND WED =  '::WED::') ORDER BY wtd ASC "
fp_sDefault="Project=SR06.000.000000&WED=01/05/2007&Project=SR06.000.000000&WED=01/05/2007"
fp_sNoRecords="<tr><td colspan=1 align=""LEFT"" width=""100%"">No records returned.</td></tr>"
fp_sDataConn="wplrv2"
fp_iMaxRecords=1
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice="Total wtd"
fp_sMenuValue="Total wtd"
fp_sColTypes="&Total wtd=5&ID=3&Employee Name=202&wtd=5&Project=202&WED=135&mtd=5&ytd=5&itd=5&"
fp_iDisplayCols=1
fp_fCustomQuery=True
BOTID=2
fp_iRegion=BOTID

fp_sQry="SELECT *,(SELECT sum(mtd) FROM LaborCum WHERE (Project LIKE '::Project::%'AND WED =  '::WED::')) as [Total mtd] FROM LaborCum WHERE (Project LIKE '::Project::%'AND WED =  '::WED::') ORDER BY mtd ASC "
fp_sDefault="Project=SR06.000.000000&WED=01/05/2007&Project=SR06.000.000000&WED=01/05/2007"
fp_sNoRecords="<tr><td colspan=1 align=""LEFT"" width=""100%"">No records returned.</td></tr>"
fp_sDataConn="wplrv2"
fp_iMaxRecords=1
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice="Total mtd"
fp_sMenuValue="Total mtd"
fp_sColTypes="&Total mtd=5&ID=3&Employee Name=202&wtd=5&Project=202&WED=135&mtd=5&ytd=5&itd=5&"
fp_iDisplayCols=1
fp_fCustomQuery=True
BOTID=2
fp_iRegion=BOTID
%>

<!--#include file="../_fpclass/fpdbrgn1.inc"-->
<tr>
<td>
<p align="right">
<%=FormatNumber(FP_FieldVal(fp_rs,"Total wtd"),1)%></td>
<td>
<p align="right">
<%=FormatNumber(FP_FieldVal(fp_rs,"Total mtd"),1)%></td>
Avatar of stevbe
stevbe

please post just the line of code you are using to build the SQL statement that is failing
Avatar of JoeStone
JoeStone

ASKER

stevbe,
Here's the code that's causing the problem:
<% end if %>
<%
fp_sQry="SELECT *,(SELECT sum(wtd) FROM LaborCum WHERE (Project LIKE '::Project::%'AND WED =  '::WED::')) as [Total wtd] FROM LaborCum WHERE (Project LIKE '::Project::%'AND WED =  '::WED::') ORDER BY wtd ASC "
fp_sDefault="Project=SR06.000.000000&WED=01/05/2007&Project=SR06.000.000000&WED=01/05/2007"
fp_sNoRecords="<tr><td colspan=1 align=""LEFT"" width=""100%"">No records returned.</td></tr>"
fp_sDataConn="wplrv2"
fp_iMaxRecords=1
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice="Total wtd"
fp_sMenuValue="Total wtd"
fp_sColTypes="&Total wtd=5&ID=3&Employee Name=202&wtd=5&Project=202&WED=135&mtd=5&ytd=5&itd=5&"
fp_iDisplayCols=1
fp_fCustomQuery=True
BOTID=2
fp_iRegion=BOTID

fp_sQry="SELECT *,(SELECT sum(mtd) FROM LaborCum WHERE (Project LIKE '::Project::%'AND WED =  '::WED::')) as [Total mtd] FROM LaborCum WHERE (Project LIKE '::Project::%'AND WED =  '::WED::') ORDER BY mtd ASC "
fp_sDefault="Project=SR06.000.000000&WED=01/05/2007&Project=SR06.000.000000&WED=01/05/2007"
fp_sNoRecords="<tr><td colspan=1 align=""LEFT"" width=""100%"">No records returned.</td></tr>"
fp_sDataConn="wplrv2"
fp_iMaxRecords=1
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice="Total mtd"
fp_sMenuValue="Total mtd"
fp_sColTypes="&Total mtd=5&ID=3&Employee Name=202&wtd=5&Project=202&WED=135&mtd=5&ytd=5&itd=5&"
fp_iDisplayCols=1
fp_fCustomQuery=True
BOTID=2
fp_iRegion=BOTID
%>

<!--#include file="../_fpclass/fpdbrgn1.inc"-->
<tr>
<td width="551">
<p align="right">
<%=FormatNumber(FP_FieldVal(fp_rs,"Total wtd"),1)%></td>
<td width="0">
<p align="right">
<%=FormatNumber(FP_FieldVal(fp_rs,"Total mtd"),1)%></td>
<td width="105">
Avatar of stevbe
stevbe

why do you repeat the same exact code?

<when I try to add additional summations, such as mtd. I get an error message.>

You could just build the query in Access with a parameter for the and then just create a paramter object, append that to a command object (that is what you use for a query in Access) and then open it ... much easier and there would be no im-line SQL to try and fix up.

Steve
Avatar of JoeStone
JoeStone

ASKER

Not sure what you mean by repeating the exact same code? What I've done is duplicated the code that worked for summing one column of data
 (<% end if %>
<%
fp_sQry="SELECT *,(SELECT sum(wtd) FROM LaborCum WHERE (Project LIKE '::Project::%'AND WED =  '::WED::')) as [Total wtd] FROM LaborCum WHERE (Project LIKE '::Project::%'AND WED =  '::WED::') ORDER BY wtd ASC "
fp_sDefault="Project=SR06.000.000000&WED=01/05/2007&Project=SR06.000.000000&WED=01/05/2007"
fp_sNoRecords="<tr><td colspan=1 align=""LEFT"" width=""100%"">No records returned.</td></tr>"
fp_sDataConn="wplrv2"
fp_iMaxRecords=1
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice="Total wtd"
fp_sMenuValue="Total wtd"
fp_sColTypes="&Total wtd=5&ID=3&Employee Name=202&wtd=5&Project=202&WED=135&mtd=5&ytd=5&itd=5&"
fp_iDisplayCols=1
fp_fCustomQuery=True
BOTID=2
fp_iRegion=BOTID
<!--#include file="../_fpclass/fpdbrgn1.inc"-->
<tr>
<td width="551">
<p align="right">
<%=FormatNumber(FP_FieldVal(fp_rs,"Total wtd"),1)%></td>)
And changed the fields that I wanted summed.

As for building the query in Access, I've never had any success at getting the web page to correctly interface with the query.

Joe
Avatar of JoeStone
JoeStone

ASKER

Please remove this question. Solved the problem on my own.
ASKER CERTIFIED SOLUTION
Avatar of JoeStone
JoeStone

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Microsoft Access
Microsoft Access

Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.

226K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo