Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Help me! Display Field Post Reply Post New Topic
Page  of 2 Next >>
Author Message
OKsoccer24
Newbie
Newbie


Joined: 05 Jun 2008
Online Status: Offline
Posts: 35
Quote OKsoccer24 Replybullet Topic: Help me! Display Field
     Posted: 09 Sep 2009 at 12:50pm
I have

 Table A                          Table B
  Proj_id                    Proj_id      Afe
   545                           545           23
                                    545           24

Most data is coming from Table A but I need to display column AFE in the page header.  Right now in the report I only see 23.  How can I see 23 & 24?
The tables are linked by Proj_id.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 09 Sep 2009 at 1:58pm
The short answer is: not easily, but it is possible.
 
Do you want to display "23 & 24" or is there another format for this display?
 
-Dell
IP IP Logged
OKsoccer24
Newbie
Newbie


Joined: 05 Jun 2008
Online Status: Offline
Posts: 35
Quote OKsoccer24 Replybullet Posted: 09 Sep 2009 at 2:09pm
Yes 23 & 24. 
IP IP Logged
rahulwalawalkar
Senior Member
Senior Member
Avatar

Joined: 08 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 731
Quote rahulwalawalkar Replybullet Posted: 10 Sep 2009 at 4:41am
Hi
 
Create a function in sql

Create FUNCTION [dbo].[ufn_projdata] ( @projid varchar(50) )RETURNS varchar(8000)AS

BEGIN

declare @DelimitedString varchar(500)

SELECT @DelimitedString = isnull(@DelimitedString + ', ', '') + cast(b.afe as varchar(20))

FROM tab_a a

inner join tab_b b on a.projid = b.proj_id

WHERE a.projid = @projid

RETURN @DelimitedString

END

then use the sql below

select projid,[dbo].[ufn_projdata] (a.projid)

from tab_a a

output
projid afe
545    23, 24
 
cheers
Rahul
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 10 Sep 2009 at 6:53am

You can also do this using a subreport to display just the data for those two records.

1. Create the subreport, use Table B only, link on {TableA.Proj_Id}.

2.  In the subreport, create a group on {TableB.Proj_ID}.  Suppress ALL sections excep the Group Footer.
 
3. Create a formula in the subreport.  It will look something like this:
 
StringVar combinedAFE;
if PreviousIsNull({TableB.Proj_ID}) then 
  combinedAFE := {TableB.afe}
else
  combinedAFE := combinedAFE + ' & ' + {TableB.afe};
combinedAFE
 
4.  Put this formula in the group footer.
 
-Dell
IP IP Logged
OKsoccer24
Newbie
Newbie


Joined: 05 Jun 2008
Online Status: Offline
Posts: 35
Quote OKsoccer24 Replybullet Posted: 10 Sep 2009 at 7:05am
Only shows &23
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 10 Sep 2009 at 7:52am
Please post your formula.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 10 Sep 2009 at 8:23am
I think the field was placed in the report footer, not the group footer.
IP IP Logged
OKsoccer24
Newbie
Newbie


Joined: 05 Jun 2008
Online Status: Offline
Posts: 35
Quote OKsoccer24 Replybullet Posted: 10 Sep 2009 at 10:49am
StringVar combinedPC;
if PreviousIsNull({Command.PROJ_ID}) then
  combinedPC := {Command.PROPERTY_CODE}
else
  combinedPC := combinedPC + ' & ' + {Command.PROPERTY_CODE};
combinedPC

I put it in the Group Footer.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 13 Sep 2009 at 8:09pm
Try this:
 
StringVar combinedPC = '';
if PreviousIsNull({Command.PROJ_ID}) or (not IsNull(({Command.PROJ_ID})  and combinedPC = '') then
  combinedPC := {Command.PROPERTY_CODE}
else
  combinedPC := combinedPC + ' & ' + {Command.PROPERTY_CODE};
combinedPC
-Dell
IP IP Logged
Page  of 2 Next >>
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