Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Problem trying to combine two fields Post Reply Post New Topic
Author Message
Neales
Newbie
Newbie


Joined: 01 Feb 2012
Online Status: Offline
Posts: 13
Quote Neales Replybullet Topic: Problem trying to combine two fields
     Posted: 01 Feb 2012 at 11:18pm
Firstly I'm a beginner so go easy on me.
 
I'm trying to combine two fields using {field1}&{field2}
 
Now this works depending on the two fields I try to combine.
 
For the particular fields I'm trying to combine if I put the fields into the report separately the information appears if I try to combine them only the information from {field2} appears.
 
Does anyone know why this happens and a way round it?
 
Thanks


Edited by Neales - 01 Feb 2012 at 11:18pm
IP IP Logged
jbalbo
Senior Member
Senior Member
Avatar

Joined: 17 Feb 2011
Online Status: Offline
Posts: 219
Quote jbalbo Replybullet Posted: 02 Feb 2012 at 3:50am
Have you tried using a formula or an Insert Text Object?

formula would be field1+field2 or field1+" "+field2 for a space between



Edited by jbalbo - 02 Feb 2012 at 3:52am
IP IP Logged
Neales
Newbie
Newbie


Joined: 01 Feb 2012
Online Status: Offline
Posts: 13
Quote Neales Replybullet Posted: 02 Feb 2012 at 4:20am

Yeah I've tried that Confused

IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 02 Feb 2012 at 4:41am

are these 2 fields from the same table?

Do you have any NULL values?
Are you placing them on the detail section?
What are the data types for each?
IP IP Logged
Neales
Newbie
Newbie


Joined: 01 Feb 2012
Online Status: Offline
Posts: 13
Quote Neales Replybullet Posted: 02 Feb 2012 at 5:13am
1) Yes, the fields are from the same table. I have even tried doing it so the fields are from different tables.
 
2) There are some null values in field2
 
3) Yes, I am placing them in the details section
 
4) Both fields are text. Field1 is a customer account name and field2 is the customers site name if it is different from the customer account name this is why it is sometimes a null value.
 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 02 Feb 2012 at 5:21am

NULLs can impact your formula in ways that you may not expect.

Unless you have set the report or the formula to use default values for NULL and you do not tell the formula how to handle the NULL then it will stop evaluating the formula when it hits the null and return nothing.
 
The easiest solution, if you have the option in your version, is in the formula editor to change the drop down option from 'exceptions for nulls' to 'default values for nulls'
 
if not you can write the fomrula to handle it:
 
if isnull({table.field2}) then {table.field1}
else
{table.field1} & " " & {table.field2}


Edited by DBlank - 02 Feb 2012 at 5:22am
IP IP Logged
Neales
Newbie
Newbie


Joined: 01 Feb 2012
Online Status: Offline
Posts: 13
Quote Neales Replybullet Posted: 02 Feb 2012 at 5:29am

Tried the "use default values for NULL" and that and it word a treat!

Big%20smile
 
Thank you very much for your help
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