It worked Scott. Thanks all again... -----Original Message----- From: Scott Brady [mailto:[EMAIL PROTECTED] Sent: Thursday, July 24, 2003 1:59 PM To: CF-Talk Subject: Re: convert to number
---------- Original Message ---------------------------------- From: "Robert Orlini" <[EMAIL PROTECTED]> >Why does this statement generate a "Cannot convert to number" error? > ><CFQUERY name="getorderid" datasource="printprices"> >Select max(orderid) as orderID from purchases ></cfquery> > ><CFIF getorderid.recordcount EQ 0> ><CFSET orderid=1001> ><CFELSE> ><CFSET orderid = getorderid.orderid + 1> ></CFIF> This may be database-specific, but I've seen instances where if the purchases table is empty (meaning there is no max(orderid)), the query will return a row with an empty string for the value of the max(orderid). So, even in that case, it's going to the else statement. Try this: <CFIF getorderid.recordcount EQ 0 OR VAL(getorderid.orderid) EQ 0> Scott -------------------------------- Scott Brady http://www.scottbrady.net/ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Get the mailserver that powers this list at http://www.coolfusion.com Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4