ssdanish
asked on
CFLoop error
I'm trying to calculate a sum in the following ColdFusion document. When I do this sum with a dollar value, it works, and when I leave out the sum (just do line-by-line detail), it works. When I try to run the following document, I get this error: 'The value "" cannot be converted to a number'
<cfquery name="campaign07" datasource="Pluto" dbtype="ODBC">
SELECT ORGNAME1 AS Name, LDR_ORG_2006_UWSVANNUALCA_ NBROFLEADE RS_ALLLEAD ERS AS LdrN06
FROM dbo.DATAEXTRACTANDARCAMPAI GN2006S
</cfquery>
<cfheader name="Content-Disposition" value="inline;filename=Cam paignUpdat e.xls">
<cfcontent type="application/msexcel" >
<Table border="1" cellspacing="1">
<thead>
<tr>
<td>Name</td>
<td>LdrN06</td>
</tr>
</thead>
<cfset MyLdrN06 = 0>
<tbody>
<cfoutput query="campaign07">
<tr>
<td>#Name#</td>
<td>#NumberFormat(LdrN06," 99,999,999 ")#</td>
</tr>
<cfset MyLdrN06 = MyLdrN06 + LdrN06>
</cfoutput>
</tbody>
<tfoot>
<cfoutput>
<tr>
<td>TOTALS</td>
<td>#NumberFormat(MyLdrN06 ,"99,999,9 99")#</td>
</tr>
</cfoutput>
</tfoot>
</table>
<cfquery name="campaign07" datasource="Pluto" dbtype="ODBC">
SELECT ORGNAME1 AS Name, LDR_ORG_2006_UWSVANNUALCA_
FROM dbo.DATAEXTRACTANDARCAMPAI
</cfquery>
<cfheader name="Content-Disposition"
<cfcontent type="application/msexcel"
<Table border="1" cellspacing="1">
<thead>
<tr>
<td>Name</td>
<td>LdrN06</td>
</tr>
</thead>
<cfset MyLdrN06 = 0>
<tbody>
<cfoutput query="campaign07">
<tr>
<td>#Name#</td>
<td>#NumberFormat(LdrN06,"
</tr>
<cfset MyLdrN06 = MyLdrN06 + LdrN06>
</cfoutput>
</tbody>
<tfoot>
<cfoutput>
<tr>
<td>TOTALS</td>
<td>#NumberFormat(MyLdrN06
</tr>
</cfoutput>
</tfoot>
</table>
ASKER
great; that worked; thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
That means you're trying to use a string "" where a number is expected. I don't know which line is throwing the error, but try using the Val() function. It will convert non-numeric values like "" to 0.
<cfset MyLdrN06 = MyLdrN06 + val(LdrN06)>