Search code examples
crystal-reports

Can we set barcode size conditionally in Crystal Reports?


I am using crystal reports with visual studio to generate a barcode report using the following formula

if Length({table.column1})>0 then
'*' + {table.column1} + '*'
Else
""

It is working fine but I want to conditionally set the barcode size.

From here i got to know how to execute nested if else in Crystal reports -

Nested if else in Crystal Reports

But when i try to implement the same in the above formula it gives me error.

I want :

If column1 is less than 10 
Then 
Font be 20 
Else
Font be 18

What I tried:

if Length({table.column1})>0 
then
(
'*' + {table.column1} + '*';
If Length({table.column1})<10
Then
20
Else
18
)
Else
""

I get error that A number is required here in else ""


Solution

  • The expression for the font size needs to be provided in a completely different location:

    Right-click the formula field on the report layout. Select Format Field...
    Select the Font tab. Enter the formula using the button for the font size expression: enter image description here