johnnyc313
asked on
Type Mismatch: formatnumber
Hi,
I have a little asp application that calculates users monthly bill. I give the option to show the bill per month either by individual customer, or show all customers bills.
When I show the bill individually the format number works fine, but when I use it when showing all customers bills, I get a type mismatch:'formatnumber' error.
I don't understand as it is the same code that I have copy/pasted from the individual one.
Any ideas?
I have a little asp application that calculates users monthly bill. I give the option to show the bill per month either by individual customer, or show all customers bills.
When I show the bill individually the format number works fine, but when I use it when showing all customers bills, I get a type mismatch:'formatnumber' error.
I don't understand as it is the same code that I have copy/pasted from the individual one.
Any ideas?
Can you post your code Johnny?
ASKER
This is the code that works:
<% IF rsInvoice.eof then %>
<td height="18" valign="top" class="normaltext">No Invoice Generated For This Month</td>
<tr>
<td height="18" valign="top" class="smallbold"><a href="customers.asp?Custom erId=<%=rs CustomerDe tails("Cus tomerId")% >">Back</a ></td>
</tr>
<% Else %>
<%'response.ContentType="a pplication /msword"%>
<table width="667" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td height="188" colspan="3" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="212" height="36"> </td>
<td width="123"> </td>
<td width="332" rowspan="4" valign="top"><!--DWLayoutE mptyCell-- > </t d>
</tr>
<tr>
<td height="19" valign="top" class="smallbold">Invoice To: </td>
<td> </td>
</tr>
<tr>
<td height="19" valign="top" class="normaltext"><%=rsCu stomerDeta ils("Custo merName")% ></td>
<td> </td>
</tr>
<tr>
<td height="19" valign="top" class="normaltext"><%=rsCu stomerDeta ils("Locat ion")%></t d>
<td> </td>
</tr>
<tr>
<td height="19" valign="top" class="normaltext">Glasgow </td>
<td> </td>
<td></td>
</tr>
<tr>
<td height="19" valign="top"><!--DWLayoutE mptyCell-- > </t d>
<td> </td>
<td></td>
</tr>
<tr>
<td height="19" valign="top" class="normaltext">Tel: <%=rsCustomerDetails("Cont actNumber" )%></td>
<td> </td>
<td></td>
</tr>
<tr>
<td height="20"> </td>
<td> </td>
<td></td>
</tr>
<tr>
<td height="18" valign="top" class="smallbold">Invoice Date: <%= rsInvoice("InvoiceDate") %></td>
<td colspan="2" valign="top" class="normaltext"></td>
<% if not rsInvoice.eof then %>
<% end if %>
</tr>
</table></td>
</tr>
<tr>
<td height="209" colspan="3" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td height="22" colspan="3" valign="top" class="smallbold">Service Description </td>
<td colspan="2" valign="top" class="smallbold"><div align="left">Amount</div>< /td>
<td width="5"></td>
</tr>
<% do while not rsInvoice.eof %>
<tr>
<td height="19" colspan="3" valign="top" class="normaltext"><%= rsInvoice("Description") %></td>
<td colspan="2" valign="top" class="normaltext">£ <%= formatnumber(rsInvoice("Am ount")) %></td>
<td></td>
</tr>
<% rsInvoice.MoveNext
Loop %>
<tr>
<td width="337" height="19"></td>
<td width="125"></td>
<td width="18"></td>
<td width="55"> </td>
<td width="127"> </td>
<td></td>
</tr>
<% totalvat=(totalCost("total Cost")*0.1 75) %>
<% invoiceamount = (totalCost("totalCost")+to talvat) %>
<tr>
<td height="18" colspan="2" valign="top" class="smallbold"><div align="right">Cost: </div></td>
<td></td>
<td colspan="2" valign="top" class="normaltext">£<%=for matnumber( totalCost( "totalCost "))%></td>
<td></td>
</tr>
<tr>
<td height="1"></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="19" colspan="2" valign="top" class="smallbold"><div align="right">VAT @ 17.5 %: </div></td>
<td> </td>
<td colspan="2" valign="top" class="normaltext">£ <%= formatnumber(totalvat, 2) %></td>
<td></td>
</tr>
<tr>
<td height="14"></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="33" colspan="2" valign="top" class="smallbold"><div align="right">Invoice Amount: </div></td>
<td> </td>
<td colspan="2" valign="top" class="normaltext">£ <%= formatnumber(invoiceamount , 2) %> </td>
<td></td>
</tr>
<tr>
<td height="34"> </td>
<td> </td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="30"> </td>
<td colspan="3" valign="top" class="smallbold"><div align="right"><a href="#" onClick="window.print()">P rint Invoice </a></div></td>
<td> </td>
<td></td>
</tr>
</table></td>
</tr>
<tr>
<td width="338" height="37"> </td>
<td width="197" valign="top" class="smallbold"><div align="right"><a href="customers.asp?Custom erId=<%=rs CustomerDe tails("Cus tomerId") %>">Back to Summary </a></div></td>
<td width="132"> </td>
</tr>
</table>
</body>
</html>
<% End If %>
This is the code that doesn't:
<% do while not rsCustomerDetails.eof
Dim rsInvoice
Dim stringSQL
Set rsInvoice = Server.CreateObject("ADODB .Recordset ")
'strSQL = "SELECT Customer.*, CustomerServices.* FROM Customer, CustomerServices WHERE Customer.CustomerId = CustomerServices.CustomerI d AND Customer.CustomerId=" & request.QueryString("Custo merId")
stringSQL = "SELECT * FROM Invoice WHERE CustomerId="& rsCustomerDetails("Custome rId") & " and Format(InvoiceDate,'m')="& invoicemonth
rsInvoice.open stringSQL, conCurrent
Dim totalCost
set totalCost = Server.CreateObject("ADODB .Recordset ")
strSQL = "Select Sum(Amount) as totalCost from Invoice Where CustomerId=" & rsCustomerDetails("Custome rId") & " and Format(InvoiceDate,'m')="& invoicemonth
totalCost.open strSQL, conCurrent
%>
<%'response.ContentType="a pplication /msword"%>
<table width="667" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="667" height="93" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="212" height="36"> </td>
<td width="79"> </td>
<td width="44"> </td>
<td colspan="3" rowspan="4" valign="top"><!--DWLayoutE mptyCell-- > </t d>
</tr>
<tr>
<td height="19" valign="top" class="smallbold">Invoice To: </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="19" valign="top" class="normaltext"><%=rsCu stomerDeta ils("Custo merName")% ></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="19" valign="top" class="normaltext"><%=rsCu stomerDeta ils("Locat ion")%></t d>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="19" valign="top" class="normaltext">Glasgow </td>
<td> </td>
<td> </td>
<td width="93"></td>
<td width="195"></td>
<td width="44"></td>
</tr>
<tr>
<td height="19" valign="top"><!--DWLayoutE mptyCell-- > </t d>
<td> </td>
<td> </td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="19" valign="top" class="normaltext">Tel: <%=rsCustomerDetails("Cont actNumber" )%></td>
<td> </td>
<td> </td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="18"></td>
<td></td>
<td colspan="2" valign="top" class="smallbold">Invoice Date: </td>
<% IF not rsInvoice.eof then %>
<td valign="top" class="normaltext"><%=rsIn voice("Inv oiceDate") %></td>
<% End If %>
<td></td>
</tr>
<tr>
<td height="1"></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="19" colspan="2" valign="top"><!--DWLayoutE mptyCell-- > </t d>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table></td>
</tr>
<tr>
<td height="189" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td height="22" colspan="2" valign="top" class="smallbold">Service Description </td>
<td width="182" valign="top" class="smallbold">Amount</ td>
<td width="5"></td>
</tr>
<% do while not rsInvoice.eof %>
<tr>
<td height="19" colspan="2" valign="top" class="normaltext"><%=rsIn voice("Des cription") %></td>
<td valign="top" class="normaltext">£ <%= formatnumber(rsInvoice("Am ount"), 2) %></td>
<td></td>
</tr>
<% rsInvoice.MoveNext
Loop %>
<tr>
<td width="454" height="19"></td>
<td width="26"></td>
<td> </td>
<td></td>
</tr>
<% totalvat=(totalCost("total Cost")*0.1 75) %>
<% invoiceamount = totalCost("totalCost")+tot alvat %>
<tr>
<td height="18" valign="top" class="smallbold"><div align="right">Cost: </div></td>
<td></td>
<td valign="top" class="normaltext">£<%=tot alCost("to talCost")% ></td>
<td></td>
</tr>
<tr>
<td height="1"></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="19" valign="top" class="smallbold"><div align="right">VAT @ 17.5 %: </div></td>
<td> </td>
<td valign="top" class="normaltext">£ <%= formatnumber(totalvat, 2) %></td>
<td></td>
</tr>
<tr>
<td height="14"></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="33" valign="top" class="smallbold"><div align="right">Invoice Amount: </div></td>
<td> </td>
<td valign="top" class="normaltext">£ <%= formatnumber(invoiceamount ,2) %> </td>
<td></td>
</tr>
<tr>
<td height="45"></td>
<td></td>
<td></td>
<td></td>
</tr>
</table></td>
</tr>
<tr>
<td height="56"> </td>
</tr>
</table>
<BLOCKQUOTE><H3></H3></BLO CKQUOTE>
<% rsCustomerDetails.Movenext
loop %>
<% IF rsInvoice.eof then %>
<td height="18" valign="top" class="normaltext">No Invoice Generated For This Month</td>
<tr>
<td height="18" valign="top" class="smallbold"><a href="customers.asp?Custom
</tr>
<% Else %>
<%'response.ContentType="a
<table width="667" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td height="188" colspan="3" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="212" height="36"> </td>
<td width="123"> </td>
<td width="332" rowspan="4" valign="top"><!--DWLayoutE
</tr>
<tr>
<td height="19" valign="top" class="smallbold">Invoice To: </td>
<td> </td>
</tr>
<tr>
<td height="19" valign="top" class="normaltext"><%=rsCu
<td> </td>
</tr>
<tr>
<td height="19" valign="top" class="normaltext"><%=rsCu
<td> </td>
</tr>
<tr>
<td height="19" valign="top" class="normaltext">Glasgow
<td> </td>
<td></td>
</tr>
<tr>
<td height="19" valign="top"><!--DWLayoutE
<td> </td>
<td></td>
</tr>
<tr>
<td height="19" valign="top" class="normaltext">Tel: <%=rsCustomerDetails("Cont
<td> </td>
<td></td>
</tr>
<tr>
<td height="20"> </td>
<td> </td>
<td></td>
</tr>
<tr>
<td height="18" valign="top" class="smallbold">Invoice Date: <%= rsInvoice("InvoiceDate") %></td>
<td colspan="2" valign="top" class="normaltext"></td>
<% if not rsInvoice.eof then %>
<% end if %>
</tr>
</table></td>
</tr>
<tr>
<td height="209" colspan="3" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td height="22" colspan="3" valign="top" class="smallbold">Service Description </td>
<td colspan="2" valign="top" class="smallbold"><div align="left">Amount</div><
<td width="5"></td>
</tr>
<% do while not rsInvoice.eof %>
<tr>
<td height="19" colspan="3" valign="top" class="normaltext"><%= rsInvoice("Description") %></td>
<td colspan="2" valign="top" class="normaltext">£
<td></td>
</tr>
<% rsInvoice.MoveNext
Loop %>
<tr>
<td width="337" height="19"></td>
<td width="125"></td>
<td width="18"></td>
<td width="55"> </td>
<td width="127"> </td>
<td></td>
</tr>
<% totalvat=(totalCost("total
<% invoiceamount = (totalCost("totalCost")+to
<tr>
<td height="18" colspan="2" valign="top" class="smallbold"><div align="right">Cost: </div></td>
<td></td>
<td colspan="2" valign="top" class="normaltext">£<%=for
<td></td>
</tr>
<tr>
<td height="1"></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="19" colspan="2" valign="top" class="smallbold"><div align="right">VAT @ 17.5 %: </div></td>
<td> </td>
<td colspan="2" valign="top" class="normaltext">£
<td></td>
</tr>
<tr>
<td height="14"></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="33" colspan="2" valign="top" class="smallbold"><div align="right">Invoice Amount: </div></td>
<td> </td>
<td colspan="2" valign="top" class="normaltext">£
<td></td>
</tr>
<tr>
<td height="34"> </td>
<td> </td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="30"> </td>
<td colspan="3" valign="top" class="smallbold"><div align="right"><a href="#" onClick="window.print()">P
<td> </td>
<td></td>
</tr>
</table></td>
</tr>
<tr>
<td width="338" height="37"> </td>
<td width="197" valign="top" class="smallbold"><div align="right"><a href="customers.asp?Custom
<td width="132"> </td>
</tr>
</table>
</body>
</html>
<% End If %>
This is the code that doesn't:
<% do while not rsCustomerDetails.eof
Dim rsInvoice
Dim stringSQL
Set rsInvoice = Server.CreateObject("ADODB
'strSQL = "SELECT Customer.*, CustomerServices.* FROM Customer, CustomerServices WHERE Customer.CustomerId = CustomerServices.CustomerI
stringSQL = "SELECT * FROM Invoice WHERE CustomerId="& rsCustomerDetails("Custome
rsInvoice.open stringSQL, conCurrent
Dim totalCost
set totalCost = Server.CreateObject("ADODB
strSQL = "Select Sum(Amount) as totalCost from Invoice Where CustomerId=" & rsCustomerDetails("Custome
totalCost.open strSQL, conCurrent
%>
<%'response.ContentType="a
<table width="667" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="667" height="93" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="212" height="36"> </td>
<td width="79"> </td>
<td width="44"> </td>
<td colspan="3" rowspan="4" valign="top"><!--DWLayoutE
</tr>
<tr>
<td height="19" valign="top" class="smallbold">Invoice To: </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="19" valign="top" class="normaltext"><%=rsCu
<td> </td>
<td> </td>
</tr>
<tr>
<td height="19" valign="top" class="normaltext"><%=rsCu
<td> </td>
<td> </td>
</tr>
<tr>
<td height="19" valign="top" class="normaltext">Glasgow
<td> </td>
<td> </td>
<td width="93"></td>
<td width="195"></td>
<td width="44"></td>
</tr>
<tr>
<td height="19" valign="top"><!--DWLayoutE
<td> </td>
<td> </td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="19" valign="top" class="normaltext">Tel: <%=rsCustomerDetails("Cont
<td> </td>
<td> </td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="18"></td>
<td></td>
<td colspan="2" valign="top" class="smallbold">Invoice Date: </td>
<% IF not rsInvoice.eof then %>
<td valign="top" class="normaltext"><%=rsIn
<% End If %>
<td></td>
</tr>
<tr>
<td height="1"></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="19" colspan="2" valign="top"><!--DWLayoutE
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table></td>
</tr>
<tr>
<td height="189" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td height="22" colspan="2" valign="top" class="smallbold">Service Description </td>
<td width="182" valign="top" class="smallbold">Amount</
<td width="5"></td>
</tr>
<% do while not rsInvoice.eof %>
<tr>
<td height="19" colspan="2" valign="top" class="normaltext"><%=rsIn
<td valign="top" class="normaltext">£
<td></td>
</tr>
<% rsInvoice.MoveNext
Loop %>
<tr>
<td width="454" height="19"></td>
<td width="26"></td>
<td> </td>
<td></td>
</tr>
<% totalvat=(totalCost("total
<% invoiceamount = totalCost("totalCost")+tot
<tr>
<td height="18" valign="top" class="smallbold"><div align="right">Cost: </div></td>
<td></td>
<td valign="top" class="normaltext">£<%=tot
<td></td>
</tr>
<tr>
<td height="1"></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="19" valign="top" class="smallbold"><div align="right">VAT @ 17.5 %: </div></td>
<td> </td>
<td valign="top" class="normaltext">£
<td></td>
</tr>
<tr>
<td height="14"></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="33" valign="top" class="smallbold"><div align="right">Invoice Amount: </div></td>
<td> </td>
<td valign="top" class="normaltext">£
<td></td>
</tr>
<tr>
<td height="45"></td>
<td></td>
<td></td>
<td></td>
</tr>
</table></td>
</tr>
<tr>
<td height="56"> </td>
</tr>
</table>
<BLOCKQUOTE><H3></H3></BLO
<% rsCustomerDetails.Movenext
loop %>
What line number are you getting back on the error, and can you post that too, the specific code on that line? Is it the totalcost that's failing?
ASKER
<td valign="top" class="normaltext">£ <%= formatnumber(totalvat, 2) %></td>
This is the line that gives me the error. If I take out the formatnumber then the error comes on this line:
<td valign="top" class="normaltext">£ <%= formatnumber(invoiceamount ,2) %> </td>
This is the line that gives me the error. If I take out the formatnumber then the error comes on this line:
<td valign="top" class="normaltext">£
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Great Stuff, that worked.
Thanks for all your help.
Thanks for all your help.