Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling A Report Function From a Report Text Field

Status
Not open for further replies.

msflinx

Programmer
Mar 11, 2003
16
US
I am trying to reformat a string, if it is numeric, to look like money ($999,999.99). Otherwise, return the string unchanged.

I have written the follwoing code in the report properties code tab:

Public Shared Function funFormatString(strToBeFormated as String) as string

dim intLen as integer

IF isnumeric(strToBeFormated)
intLen = len(strToBeFormated)
SELECT CASE intLen
CASE 1 to 6
strToBeFormated = "$" + strToBeFormated
CASE 7 to 9
strToBeFormated = "$" + left(strToBeFormated, intLen - 6) + "," + right(strToBeFormated, 6)
CASE 10 to 12
strToBeFormated = "$" + left(strToBeFormated, intLen - 9) + "," + mid(strToBeFormated, intLen - 6, 3) + right(strToBeFormated, 6)
END SELECT
END IF

return strToBeFormated

End Function

When I go into my text field on the report, I enter the following in the expression to call the function:

=funFormatString(Fields!Q4Amt.Value)

The error I am recieving is:

The value expression for the textbox xxx contains an error: [BC30451] Name 'funFormatString' is not declared.

What am I doing wrong?

Thanks,

msflinx


 
=Code.funFormatString(Fields!Q4Amt.Value)

also, would just using FORMAT(Fields!Q4Amt.Value,"C") work for your situation??

 
Thanks.... DUH!!! I'm an idiot.... That's just way to simple... Why didn't I figure that one out... :(

Ok -- enough of the self bashing.

Second, in answer to your question -- No, because if I use the "C" format for currency, it is upset by the "NA" field. Says it can't convert to decimal.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top