Print Page | Close Window

Crystal Report Formula Field Problem

Printed From: Crystal Reports Book
Category: Crystal Reports for Visual Studio 2005 and Newer
Forum Name: Writing Code
Forum Discription: .NET programming API, report integration
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=1302
Printed Date: 26 Apr 2024 at 9:41am


Topic: Crystal Report Formula Field Problem
Posted By: ranigoal
Subject: Crystal Report Formula Field Problem
Date Posted: 11 Sep 2007 at 12:29pm

I am new to this.

Here is my problem I have columns for city, state, zip code. The problem with that was I could not formatted nicely for example:

Raleigh             , NC 566777

 

Spring Field     , OR 5552222

 

As you can see there are a lot of empty spaces. So I created a Formula field to make it look nice

Example:

Formula1field1: this is the code behind

{command.Mailing City} + ", " + {command.Mailing State/Province} + " " + {command.Mailing Zip/Postal Code};

 

This worked fine but the problem was if I have an empty zip code which is possible it won’t display the city or state. In some other cases I might have the city and the zip code not the state.

 

So for simplicity I changed the code behind the formula field to the following:

 

if ((Not IsNull({command.Mailing City}))and (Not IsNull({command.Mailing State/Province})) and  (IsNull({command.Mailing Zip/Postal Code}))) Then

  addre := {command.Mailing City} + ", " + {command.Mailing State/Province};

 

If ((Not IsNull({command.Mailing City}))and (Not IsNull({command.Mailing State/Province})) and  (Not IsNull({command.Mailing Zip/Postal Code}))) Then

    addre := {command.Mailing City} + ", " + {command.Mailing State/Province} + " " + {command.Mailing Zip/Postal Code};

 

the problem with this it is always executing the last if Statement

 

 

can you help me plz

 



Edited by ranigoal - Today at 12:25pm



Replies:
Posted By: nbalajicec
Date Posted: 19 Nov 2007 at 9:57pm

if u r getting values from OSP means then use Decode statement..

if u know that values will return null then use decode statement..
 
And check the condition based on the decode output..
 
 
Hope u understood..



Print Page | Close Window