Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: string formula Post Reply Post New Topic
Author Message
LisaSR
Newbie
Newbie


Joined: 20 Nov 2009
Location: United States
Online Status: Offline
Posts: 5
Quote LisaSR Replybullet Topic: string formula
    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."
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet 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. 
IP IP Logged
LisaSR
Newbie
Newbie


Joined: 20 Nov 2009
Location: United States
Online Status: Offline
Posts: 5
Quote LisaSR Replybullet 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?
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet 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?
IP IP Logged
LisaSR
Newbie
Newbie


Joined: 20 Nov 2009
Location: United States
Online Status: Offline
Posts: 5
Quote LisaSR Replybullet 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.

IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet 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?

IP IP Logged
LisaSR
Newbie
Newbie


Joined: 20 Nov 2009
Location: United States
Online Status: Offline
Posts: 5
Quote LisaSR Replybullet Posted: 24 Nov 2009 at 9:19am

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

IP IP Logged
LisaSR
Newbie
Newbie


Joined: 20 Nov 2009
Location: United States
Online Status: Offline
Posts: 5
Quote LisaSR Replybullet 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!
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.