Click here to Skip to main content
15,885,899 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
How to change the font style conditionally in crystal report

i first want to check the field value is numeric or not . if the field value is numeric then
change the font style according to condition


For eg:
//student_Proc is the name of the procedure
If (isNumeric({student_proc;1.FieldValue})) then

if({student_proc;1.FieldValue}<40) then
crbold

else
crregular



In this code the isnumeric is not working properly, it always returns false even if the field value is numeric
Posted
Updated 4-Feb-14 0:54am
v2

To change the font style dynamically according to value use this expression in your expression

=Format(First(Fields!arn.Value, "opdDataSet_qph"),"BOLD")
 
Share this answer
 
Comments
[no name] 4-Feb-14 6:47am    
If you found this solution useful then accept it as answer
fiashieen 4-Feb-14 6:57am    
this answer not meeting my requirement .The prime problem is that the isnumeric is not working properly . Anyway thank u so much for your reply
To Change the Font Style Conditionally in Crystal Report-
Step 1 : Right Click the Field which you want to format conditionally
Step 2 : Select Format Object
Step 3 : Select Font Tab (in Horizontal Tabs)
Step 4 : You can see an image button near to each font attribute.
Click the Required one.(eg Style)
Step 5 : Formula Workshop will open for you. Frame the formula .
Step 6 : Press Alt+C to check errors.
Step 7 : Save and Close.


Eg of Formula :

if NumericText ({student_proc1.FieldValue}) then crBold else crRegular;

** You can get DB field from first frame in Formaula Workshop
** NumericText Function (strings) and Font Options (font style contants) from second frame of Formula Workshop .
** Control Structures from third frame
 
Share this answer
 
Comments
fiashieen 4-Feb-14 7:23am    
Thank you so much...it was a nice explanation.but in my crystal report the isNumeric condition checking is always returning a false value even if the fieldValue consist of integers.
Member 8398801 7-Dec-16 6:13am    
Tnx for the info and example
Your formula should be like below.
C#
if (IsNumeric({Student.Mark})) Then 
 if({Student.Mark} >= 40) then 
  crbold //if mark is 40 or more than 40 make the font bold - PASS
 else
  crregular //if mark is below 40 make the font regular - FAIL
else
 crregular //if mark is non-numeric/empty/NULL make the font regular - FAIL
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900