The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
		
			|  | 
			
		
			|  | 
				
					| Sum data and display in textbox.  Posted: 17 May 10 3:25 PM
 |  
					| I am trying to run a query that will sum some revenue data and then just have the sum populate a textbox.  I keep getting an error of Type Mismatch in Saleslogix.  I am currently running 7.5.1.  Can anyone tell me what I am doing wrong? Thanks!
 
 Here is the code that I am using:
 
 strSQL = "Select SUM(Revenues) TotalRevenue from sysdba.ACCOUNT_REVENUE where ACCOUNTID = '"& strVal &"' AND FISCALYEAR = '"& strYear &"'"
 
 objRS.Open strSQL, objSLXDB.Connection
 
 if objrs.eof = false then
 If objRS.Fields.Item("TotalRevenue").Value > 0 then ------- This is where the system is giving me the error message.
 txtTotalRevenue.Text = objRS.fields.item("TotalRevenue").Value
 else
 txtTotalRevenue.Text = "0.00"
 end if
 end if
 
 |  
					|  |  | 
			|  | 
				
					| Re: Sum data and display in textbox.  Posted: 18 May 10 3:25 PM
 |  
					| Have you tried something like MsgBox(objRS(0).Value) just before the error-causing line, to see what's actually in the recordset? |  
					|  |  | 
			|  | 
				
					| Re: Sum data and display in textbox.  Posted: 19 May 10 8:25 PM
 |  
					| RS data coming in is invariably/usually string, always cast locally. Always cast prior to use in an if statement. Have NEVER used your .Item property... 
 Mycurr = ccur(rs.fields(0).value)
 if mycurr > 0
 is a start
 
 but even that doesn't trap mulls
 |  
					|  |  | 
			|  | 
				
					| Re: Sum data and display in textbox.  Posted: 20 May 10 7:15 AM
 |  
					| Thanks for your suggestions.  I actually was able to get it to work by changing the FormatType of the textbox to ftCurrency. Renee
 |  
					|  |  | 
			|  |