• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 201
  • Last Modified:

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_NBROFLEADERS_ALLLEADERS AS LdrN06
FROM         dbo.DATAEXTRACTANDARCAMPAIGN2006S
</cfquery>

<cfheader name="Content-Disposition" value="inline;filename=CampaignUpdate.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,999")#</td>
</tr>
</cfoutput>
</tfoot>

</table>
0
ssdanish
Asked:
ssdanish
  • 2
1 Solution
 
_agx_Commented:
> 'The value "" cannot be converted to a number'

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)>
0
 
ssdanishAuthor Commented:
great; that worked; thanks
0
 
_agx_Commented:
Glad to assist :)  So did this answer your question?
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now