If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Problems displaying returned field as currency

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-03-04, 16:56
brodix brodix is offline
Registered User
 
Join Date: May 2004
Posts: 5
Exclamation Problems displaying returned field as currency

I've tried to modify the SQL atatement to do this but all efforts proved unsucessful. So i tried this...

<%FormatCurrency(FP_FieldVal(fp_rs,"TotalNet"))% >

That worked, but when the field contained a null I would recieve a VB Script error...


Microsoft VBScript runtime error '800a000d'

Type mismatch: 'FormatCurrency'

/test1.asp, line 26


So I tried this next...

<%If FP_FieldVal(fp_rs,"TotalNet") > NULL Then Response.write FormatCurrency(FP_FieldVal(fp_rs,"TotalNet"))%>

It looked like it worked at first but I later found that it returns nothing even if there is something to return.

So my brain is fried... Can anyone see what I am doing wrong here?
Reply With Quote
  #2 (permalink)  
Old 05-03-04, 20:34
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
you can't compare null values like that,.. try this...
Code:
<%If not(isNull(FP_FieldVal(fp_rs,"TotalNet")) Then Response.write FormatCurrency(FP_FieldVal(fp_rs,"TotalNet"))%>
Reply With Quote
  #3 (permalink)  
Old 05-04-04, 08:20
brodix brodix is offline
Registered User
 
Join Date: May 2004
Posts: 5
Quote:
Originally Posted by rokslide
you can't compare null values like that,.. try this...
Code:
<%If not(isNull(FP_FieldVal(fp_rs,"TotalNet")) Then Response.write FormatCurrency(FP_FieldVal(fp_rs,"TotalNet"))%>
It does work if there is a value to return. But it still does not work if it returns a null. I get this...


Microsoft VBScript runtime error '800a000d'

Type mismatch: 'FormatCurrency'

/test.asp, line 26

Any other thoughts. BTW thank you for your input.
Reply With Quote
  #4 (permalink)  
Old 05-04-04, 19:02
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
It makes me think that as well as nulls you have blanks....

try
Code:
<%If not(isNull(FP_FieldVal(fp_rs,"TotalNet")) and FP_FieldVal(fp_rs,"TotalNet")) <> ""Then Response.write FormatCurrency(FP_FieldVal(fp_rs,"TotalNet"))%>
btw what does the FP_FieldVal function actually do??

Last edited by rokslide; 05-04-04 at 19:13.
Reply With Quote
  #5 (permalink)  
Old 05-04-04, 19:48
Seppuku Seppuku is offline
Useless...
 
Join Date: Jul 2003
Location: SoCal
Posts: 721
First, depending on the complexity of FP_FieldVal, then you might want to call that function and store the return in a variable instead of calling it twice.

I agree with rokslide.. can we see what that function does?
__________________
That which does not kill me postpones the inevitable.
Reply With Quote
  #6 (permalink)  
Old 05-04-04, 22:07
brodix brodix is offline
Registered User
 
Join Date: May 2004
Posts: 5
I thank you for your responses, However I managed to figure it out with help from my friend. Here is what I came up with...

<% IF Trim(FP_FieldVal(fp_rs,"TotalNet")) = "&nbsp;" THEN
Response.write ("$0.00")
ELSE
Response.write (FormatCurrency(FP_FieldVal(fp_rs,"TotalNet")))
END IF%>

I used Trim to remove the space that FP_FieldVal returns when the field is Null. Then I through in an "ELSE" because it seemed logical.

Again I thank you for your efforts.
Reply With Quote
  #7 (permalink)  
Old 05-04-04, 22:23
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
Personally I'd rewrite that FP_FieldVal function it seems like a slightly silly way of doing things if I am guessing what it is doing correctly.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On