How to include function text in a formula? - crystal-reports

This is probably a very simple question, but i'm trying to write a formula which will display text depending on the value that is being run.
However, the text i require has the word "Floor" in it which is a function, therefore when i save the formula it warns me saying There is an error in this formula. Do you want to save it anyway?
Is there a way i can include the word Floor in the text, such as putting '' around the word?
For example
IF {database.column} = 3 THEN "3rd Floor"

try this, i think CR is expecting an Else statement
IF {database.column} = 3 THEN
"3rd Floor"
else ""

I found the issue, it was the fact that i had a line break in it without specifying it with Chrw().

Right-Click on feild then Formate Object & insert formula in Display string
IF {database.column} = 3 THEN '3rd Floor'

Related

strikeout/strikethrough specific text within the same column and rows in crystal reports

I have this problem where I want to strikeout a specific text in crystal reports. I mean I do not want to strikeout the entire string in that column I am using crystal reports in visual studio.
Here is the image:
I format the encumbrances column and check the strikeout as shown in the image below:
This next image is i input a script where if the string contains "*" it will strikeout the string. This is not what I wanted. What I want is that strikeout only the strings after the asterisk. I mean all of the strings after the asterisk should be strikeout and all of the strings before the asterisk should not be strikeout.
This is the result using the current script I have. As you can see all of the text is strikeout. What I want is that the text "CANCELLED" should only be strikeout since it is after the asterisk and the text "ANOTHER ENCUMBRANCES" should not be strikeout since it is before the asterisk.
How to solve this problem? Is this possible? I know my script is wrong.
As Crystal Reports can only display one font-style inside one formula field, you have to create two formulas and cut the text in two parts.
Create following formulas and put them inside a text-object.
(On the AfterAsterisk-formula tick the Strikeout-checkmark.)
BeforeAsterisk
If InStr({td_table.ENCUMBRANCES}, "*") > 0 Then
Left({td_table.ENCUMBRANCES}, InStr({td_table.ENCUMBRANCES}, "*")-1)
AfterAsterisk
If InStr({td_table.ENCUMBRANCES}, "*") > 0 Then
Mid({td_table.ENCUMBRANCES}, InStr({td_table.ENCUMBRANCES}, "*"))

IF statement with Condtional Formating Crystal

I want to do an IF statement that has 2 outcomes:
I want it to say a word
I want it to be a color
For example:
IF {Command.Check in/Appt} < 0
THEN "Early" AND crGreen
ELSE "LATE" AND crRed
In the above example the AND does not work.
A Boolean is required here.
So I just need to find a way to have those 2 outcomes
Short of using shared variables, you can't do that. One formula, one output.
But there's nothing saying you can't have two nearly identical formulas, (One for Early/Late, one for Red/Green) - And in Crystal, that's the best way to do it. (Glad to see you figured that out on your own.)
The reason the AND keyword was giving you trouble is because AND is a Boolean operator. Whenever you use AND, you're basically using this function:
Take booleans FOO and BAR as input.
I return true if, and only if, FOO and BAR are both true.
If at least one of them is false, I return false.
So the AND keyword was expecting two booleans for input. Instead you gave it a string and a color. Ask a machine if the color Red is equal to true, it's going to complain.
Ok, while I didn't find a solution by adding it in the formula, I did find a solution.
For those who have the same problem, just keep the IF statement:
IF {Command.Check in/Appt} < 0
THEN "Early"
ELSE "LATE"
Then save and go to Format > Highlight Expert to enter the formatting conditions you like.
In the above case, I did:
New > Value of: this field is equal to "Early" Font color Green
New > Value of: this field is equal to "Late" Font color Red

Formatting data in Crystal Reports

I have a field which is a Double. For display on a the report, if that value is negative, then I need to reverse the number by multiplying it by -1. The result should be formatted like this: "(1,000)" (notice no "-" sign). How can I do this in Crystal? I was using a Display String formula to try to do this since the "Reverse sign for display" option doesn't work for me (because it needs to be a formula for other reasons).
So far I have:
if {columnName} < 0 then
"(" & ToText({columnName}, "#,###", 0) & ")"
else
"(" & ToText({columnName} * -1, "#,###", 0) & ")"
But this gives me something like this: "(-6,500)", and I need to get rid of that pesky minus sign.
Edit:
I implemented a formula field like this:
-Abs({columnName})
Then selected the format that looks like (1,234) from the format list as Craig answered below.
Crystal Reports supports 'accounting' formatting w/o much effort:
right click field, select Format Field...
select Number tab (if not selected)
choose the style that resembles '(1,123.00)'
** edit **
You can also apply this formatting to a formula field.
I have accomplished my requirement this way< I have added a formula and assigned sum of the required field then I set its Format (12,34.00) also i have removed Dollar sign.
Formula = replace(totext(Sum({myfield}) * -1),"$","")
I have face same pro blame but it OS specific . ON windows xp no any formatting problem but above xp this issue face. Use following formula in Display Formula after removing all formatting .
Replace(Replace(Replace(ToText (CurrentFieldValue, "##,##,##,##0.00", 2),"$",""),"-",""),",","")

format number in ssrs report

argh!
Can't stand it that i can't figure it out myself....
i've used this in the formatting of a number in my report:
'€' #,0.00;('€' #,0.00)
and that formats to € 1,212.89
which is not exactly what i want, because i want € 1.212,89
regardless of the regional setting of the server.
So i tried this
'€' #.0,00;('€' #.0,00)
but that gives me this:
1.212.890
Typing this i realize that i don't know what the # and the . and the , mean in the format string.....
You can find the definition of the comma and period dynamic behavior here:
http://msdn.microsoft.com/en-us/library/0c899ak8.aspx
I think the best way to reliably get what you want is to hard code a locale into the expression for this field.
= (new Decimal(11123.55)).ToString("€#,0.00;(€#,0.00)",
new System.Globalization.CultureInfo("es-ES"))
This will always use the comma as decimal, and period as millions, thousands &c.
There are ways to be more dynamic and always return in the clients local set format, that would usually be preferable.
I know this is an old thread, but in case someone needs it, there is an easiest and most proper way to do it :
Right click on the Textbox of your expression
Select "Number" in the popup "Text Box Properties"
In the "Category", select "Number"
Tick the "Use 1000 separator
Click OK
To "customize" your '1000 separator':
Select the Textbox of your expression
In the Properties on the right, apply the right culture in the "Language" property.
E.g. Select "fr-CH" to have 123'456 otherwise the default is 123,456 as English separator.
Try this out. It will format your value to the correct number of decimal places.
=format(1212.89,"€#,#.00")
For indian currency, in the field value use like =Format(Fields!ServiceTaxAmt.Value,"##,##,##,###.00") and change the language value to hi-in for report property.
You can use the format € #,0.00 and set the language of your report to de-DE by clicking outside of the report area and in the right properties pane go to Localization -> Language.
This Works correctly with [set Language as hi-IN and Format as "##,##,##,###.00"]
Appreciate your Efforts
Also Same can be achieved by following Steps
Go to Text Box Properties
Select Number category in Number Tab
Check the check box beside [Use 1000 separator(,)]
Click Ok

Format (make bold or italics) a portion of a Textbox or Formula object in Crystal Reports

I am trying to format (bold or italics) only a portion of a textbox or Formula object (IFieldObject) in Crystal Reports for Visual Studio 2008.
I know how to make the entire field bold, but I want only a portion.
For example:
...blah blah blah May 12, 2009 blah blah blah...
Is this possible? I'm thinking there must be some sort of markup, but can't find any reference
to it.
You can do this by inserting HTML markup in the field (using a formula) and then displaying the new formula as a HTML field.
e.g.
Here's a basic Syntax formula that takes a field and adds the bold tag around the text before the colon.
dim sTmp as string
dim sLeft as string
dim sRight as string
dim sAll as string
sTmp = {yourtable.yourfield}
sLeft = (split(sTmp,":"))(1)
sRight = (split(sTmp,":"))(2)
sAll = "<b>"+sLeft+":</b>"+sRight
formula = sAll
If you place this new formula into the report and then ...
Right Click the field and choose "Format Field"
Change Text Interpretation to HTML Text
Click 'OK'
There are Gotchas here. The original text is not HTML encoded, and I'm sure my example code does a simple one-line thing in about ten lines. Also, if your field has no colons in it, you'll force an error. However, it should give you the right idea.
Create a formula for the date part, then embed it into a text box, then you can format any way you like
I don't know, if it is doable.
You could create a separate formula field for the value that you want to make bold & insert the formula field between other formula field, which will make it look like single sentence.