Print Page | Close Window

string formula

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=8429
Printed Date: 06 May 2024 at 12:28pm


Topic: string formula
Posted By: LisaSR
Subject: string formula
Date Posted: 20 Nov 2009 at 12:54pm

I'm creating PeachTree Accounting Balance Sheet report using Crystal Reports 2008

I'm grouping by AccountType, which is a numeric field in PeachTree but I want to display the name (f.e. "Cash" instead of 1
 
 
I clicked on "Display String" button in Format Editor / Common tab
 
I'm a newbie so I don't know the syntax
 
...  how do I write the correct string formula for the following condition?
 
If {Chart.AccountType} = 0 then “Cash” else
If {Chart.AccountType} = 1 then “Accounts Receivable” else
If {Chart.AccountType} = 4 then “Other Current Assets” else
If {Chart.AccountType} = 5 then “Fixed Assets” else
If {Chart.AccountType} = 10 then “Accounts Payable” else
If {Chart.AccountType} = 12 then “Other Current Liabilities” else
If {Chart.AccountType} = 21 then “Income” else
If {Chart.AccountType} = 24 then “Expenses” 
 
I keep getting the error: "A number, currency amount, boolean, date, time, date-time, or string is expected here."



Replies:
Posted By: DBlank
Date Posted: 20 Nov 2009 at 1:22pm
Just make this a formula field instead of uing the display string.
In the Field Explorer
right click on the Formula Field
select New
Name it
Click OK
add your formula which was wriiten correctly...
If {Chart.AccountType} = 0 then “Cash” else
If {Chart.AccountType} = 1 then “Accounts Receivable” else
If {Chart.AccountType} = 4 then “Other Current Assets” else
If {Chart.AccountType} = 5 then “Fixed Assets” else
If {Chart.AccountType} = 10 then “Accounts Payable” else
If {Chart.AccountType} = 12 then “Other Current Liabilities” else
If {Chart.AccountType} = 21 then “Income” else
If {Chart.AccountType} = 24 then “Expenses” 
 
Save and close.
Now use this fomrula field on your report cnavas instead of the original accounttype field. 


Posted By: LisaSR
Date Posted: 23 Nov 2009 at 1:13pm

Thanks for your suggestion! 

However I tried what you said creating this as a new formula field instead of a string but it still didn't work.   Even though you say my formula is correct, when I click save I always get the same error message I got before.
 
Am I missing something?


Posted By: DBlank
Date Posted: 23 Nov 2009 at 1:26pm
When you get the "A number, currency amount, boolean, date, time, date-time, or string is expected here." error it should highlight or show you where in your formula it is expecting this value. Where is it showing?


Posted By: LisaSR
Date Posted: 24 Nov 2009 at 7:38am

First of all, when I save  the forumula it gives me a msg saying
"There is an error in this formula.  Do you want to save it anyway?"

I saved it, then dragged the formula field to my report, replacing the Chart.Account.Type field.

When I run the report I just get a blank page w/ the error msg.  Nothing is printed to be highlighted.



Posted By: DBlank
Date Posted: 24 Nov 2009 at 7:54am

Sorry, I could have been clearer. When you go to save the formula it gives  the prompt on the error and do you want to save. Say no you do not want to save it. At that point it should put the curser in the formula where the error is in the formula. Where is the curser showing?



Posted By: LisaSR
Date Posted: 24 Nov 2009 at 9:19am

The cursor is flashing just before the  word "Cash" on the very first line



Posted By: LisaSR
Date Posted: 24 Nov 2009 at 9:58am
I just tried substituting ' for " and it worked.  Iguess Crystal doesn't like double quotes.
 
Thanks for your help!



Print Page | Close Window