Results 1 to 7 of 7
  1. #1
    Join Date
    May 2004
    Posts
    5

    Exclamation Unanswered: 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?

  2. #2
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    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"))%>

  3. #3
    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.

  4. #4
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    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 20:13.

  5. #5
    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.

  6. #6
    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.

  7. #7
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •