Print Page | Close Window

Formula for Enable Currency Symbol

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=11908
Printed Date: 07 May 2024 at 8:41pm


Topic: Formula for Enable Currency Symbol
Posted By: ejh21
Subject: Formula for Enable Currency Symbol
Date Posted: 20 Dec 2010 at 8:10am
I am trying to create a formula that will decide whether or not to show a floating Currency Symbol in a field in my detail band.

The currency symbol should show depending on the value of a field in my group header. For instance, if the value of my field in the group header is blank, then the field in the detail band should show a $. Unless this field is not in the detail band where the row description is not a balance.

Here is my example data:

Row Description        Amount
Beginning Balance      1000.00
Contributions                 10.00
Ending Balance          1010.00

The 1st and 3rd rows should have the $ if the character field in the group header is blank. SourceName is the character field in the group header.

Here is my code:

if SourceName = "" then
select RowDescription
    case "Beginning Balance" : crFloatingCurrencySymbol
    case "Ending Balance" : crFloatingCurrencySymbol
    default : crNoCurrencySymbol
else crNoCurrencySymbol

I have the currency symbol enabled and it is set to floating. I have this code placed in the formula box beside "Enable Currency Symbol". I've tried every combination of changing the defaults, but the field in the detail always shows the currency symbol for some reason, instead of only showing for the rows that it should. Could anyone let me know if my code looks correct?

Thanks,
Erik



Replies:
Posted By: Keikoku
Date Posted: 20 Dec 2010 at 9:08am
What method did you choose to display the row descriptions?


Posted By: ejh21
Date Posted: 20 Dec 2010 at 9:12am
The Row Descriptions are a field in the same detail section where I am displaying the amount.


Posted By: Keikoku
Date Posted: 20 Dec 2010 at 9:16am
I'm trying to reproduce something like that to get an idea what might be wrong, but I'm not sure what kind of field the RowDescription is.


Posted By: ejh21
Date Posted: 20 Dec 2010 at 9:17am
This code works when not factoring in the Group Header field to be blank.

select RowDescription
    case "Beginning Balance" : crFloatingCurrencySymbol
    case "Ending Balance" : crFloatingCurrencySymbol
    default : crNoCurrencySymbol

This code will show the $ symbol if RowDescription is Beginning of Ending Balance and no symbol shows otherwise. However, when I include the other factor of the Group Header field being blank, it seems to just revert to what is set in the default settings.


Posted By: ejh21
Date Posted: 20 Dec 2010 at 9:18am
I'm sorry. It's a character field from a table just as Amount is a numeric field from the same table. The field in the group header, "SourceName", is also a character field.


Posted By: Keikoku
Date Posted: 20 Dec 2010 at 9:21am
So then the question becomes...are they really "blank"?
It's possible that they're something else, like maybe a null char. I'm not too sure about how default values work, but that has gotten me a couple times when I assumed a field would be the empty string when it was in fact null..

Maybe you can use


if IsNull(row_description)


instead and see if it works.

EDIT: I mean group header.


Posted By: ejh21
Date Posted: 20 Dec 2010 at 9:40am
That's what it was. Thank you so much! I have been looking at this for hours wondering what it could be.



Print Page | Close Window