Writing Code
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Writing Code
Message Icon Topic: Crystal Report Formula Field Problem Post Reply Post New Topic
Author Message
ranigoal
Newbie
Newbie


Joined: 11 Sep 2007
Location: United States
Online Status: Offline
Posts: 12
Quote ranigoal Replybullet Topic: Crystal Report Formula Field Problem
    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
IP IP Logged
nbalajicec
Newbie
Newbie


Joined: 19 Sep 2007
Online Status: Offline
Posts: 10
Quote nbalajicec Replybullet 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..


Edited by nbalajicec - 19 Nov 2007 at 10:06pm
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.029 seconds.