Click to See Complete Forum and Search --> : Problem with No of Digits after period


Asim
09-14-2003, 11:54 PM
Hi
I want to show my figures with two decimal places like
25.50 .I am using single as data type in my access database with fixed option i.e. 4556.22. So in my access table I have value which is 25.50 but when I retrieve this value through ASP its Shows 25.5 .Problem is here whenever I have value which contains 0 after decimal, ASP ignores it like If I have value 25.00 then ASP shows 25 , if I have 25.50 Then ASP Shows 25.5 but If I have value 25.99 its OK with ASP or if I have 25.08 its also ok
Please help me , I also converted the datatype with cStr funtion in SQL statement but it did work.

Thanks
Asim

rdoekes
09-15-2003, 02:44 AM
formatNumber(dblNumber, 2)

THis will always give you two decimal places..

-Rogier Doekes

NatuScape
06-04-2004, 01:47 PM
Hi,

I just tried the suggested bit of code, but my query doesn't want to do it! I'm using an MS Access 2002 database and VBScript to pull up the data. Here's the bit of code that pulls the field I'm interested in and should convert it to no decimal places... alas it doesn't work.

FormatNumber(rs.Fields("InfluentCOD"),0)

The error I get is:

Microsoft VBScript runtime error '800a000d'
Type mismatch: 'FormatNumber'
/bedford80ashby/wwtp/viewloghistory.asp, line 117


Any ideas??? Thanks so much in advance!!

Me :)

CrazyC115
06-04-2004, 01:54 PM
Originally posted by NatuScape

FormatNumber(rs.Fields("InfluentCOD"),0)

The error I get is:

Microsoft VBScript runtime error '800a000d'
Type mismatch: 'FormatNumber'
/bedford80ashby/wwtp/viewloghistory.asp, line 117


Make sure that rs.fields("InfluentCOD") is actually a number. Try putting it in a CLNG() function just to make sure. Also be aware that if rs.Fields("InfluentCOD") is allowed to contain a NULL value it will cause errors with both FormatNumber and Clng. So you will have to pretest to make sure rs.Fields("InfluentCOD") is not null.

NatuScape
06-04-2004, 01:57 PM
Hi Asim,

You hit the nail right in the head! My problem was that the first record in that table had a null value and that was messing up the whole thing. I removed that record (I didn't need it) and all is solved and working perfectly.

Thanks so much!!

Natalia

CrazyC115
06-04-2004, 02:11 PM
Originally posted by NatuScape
Hi Asim,

You hit the nail right in the head! My problem was that the first record in that table had a null value and that was messing up the whole thing. I removed that record (I didn't need it) and all is solved and working perfectly.

Thanks so much!!

Natalia

Well i'm glad Asim got the credit for solving your problem ;-). I've run into crazy errors like that god knows how many times in the past... I call it the "Oh ya duh! That's solves the problem" type problem/solution that all of us run into on a regular basis :)