Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Easy one!! Post Reply Post New Topic
Author Message
charlie.lincoln
Newbie
Newbie


Joined: 18 Jun 2014
Location: United Kingdom
Online Status: Offline
Posts: 2
Quote charlie.lincoln Replybullet Topic: Easy one!!
     Posted: 18 Jun 2014 at 10:23pm
Hi all

I'm still just scratching the surface of what Crystal can do so please be gentle as i'm a real novice!

I am trying to output a postal address into my report. The only catch is i have a preference for a certain type of address. Most people on the report will have an entry in the "preferred" address table but some won't. Those that don't will have an address in a "main" address table. So what i want is to output the preferred address if it exists but if it doesn't then output the main.

I am trying to use an IF statement in a formula to do this, line by line. Below is my Address 1 line.

IF IsNull({preferred.Address1}) then {Main.Address1} else {preferred.Address1}

I then drag this into my details area. When i run the report what i find is that if the person had no entry in the "preferred" address table then it is not outputting their "main" address value.

One good result is if there is a value in the "preferred" table it does output that.

Any help is appreciated!

Thanks
Charlie
IP IP Logged
Gurbs
Senior Member
Senior Member
Avatar

Joined: 16 Feb 2012
Location: Ireland
Online Status: Offline
Posts: 216
Quote Gurbs Replybullet Posted: 19 Jun 2014 at 2:54am
What you could do to check the quality of your data, is to simple drag both the fields {main.address1} and {preferred.address1} to your report.

Otherwise, is the value in the preferred table empty, or just a space? Crystal's interpretation is different with these 2 options.

A simple formula to check how long your field is:

len({preferred.address1})

If it is a space, you can turn your formula around and build in a check to make sure it is more than 1 character:

if not isnull({preferred.address1}) and len({preferred.address1} > 1 then {preferred.address1} else {main.address1}
IP IP Logged
charlie.lincoln
Newbie
Newbie


Joined: 18 Jun 2014
Location: United Kingdom
Online Status: Offline
Posts: 2
Quote charlie.lincoln Replybullet Posted: 19 Jun 2014 at 6:25am
Thanks. Ok, i've tried this and at the moment nothing is being output when i drag this len({preferred.address1}) formula into my report.
IP IP Logged
Gurbs
Senior Member
Senior Member
Avatar

Joined: 16 Feb 2012
Location: Ireland
Online Status: Offline
Posts: 216
Quote Gurbs Replybullet Posted: 23 Jun 2014 at 11:34pm
ok, so that indicates that your field {preferred.address1} is actually empty. Can you try and create a formula:

if not isnull({preferred.address1}) and not isnull({main.address1}) then 'BOTH' else
if not isnull({preferred.address1}) and isnull({main.address1}) then 'PREFERRED' else
if isnull({preferred.address1}) and not isnull({main.address1}) then 'MAIN' else 'NONE'

Put this in your formula. Check which value this will give back. If it gives back the value NONE, it means that both tables are empty.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 24 Jun 2014 at 9:26am
How are you linking your tables together? Depending on the types of joins, it could be that you're not actually getting the Main Address data returned in the query.

-Dell
IP IP Logged
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