Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: displaying same datafield twice on report Post Reply Post New Topic
Author Message
bt_sangram
Newbie
Newbie


Joined: 08 Jul 2007
Location: India
Online Status: Offline
Posts: 5
Quote bt_sangram Replybullet Topic: displaying same datafield twice on report
    Posted: 08 Jul 2007 at 12:37am

Hi All,

I need to display a same datafield twice on my report with different conditions. When i drag and drop the same field twice on the report. I want a way to define different conditions for both these field.

I am using MS Access and Crystal reports 8.5 version. the front end of my project is Visual Basic 6

eg: I have three tables: BookMaster (Table 1) with bookId as primary key and bookName as additional field, AuthorMaster (Table 2) with authorId as Primary Key and authorName as additional field; bookAuthor (Table 3) which consists of bookId and authorId as foreign keys and authorType as text field (the field authorType is given because i need to show who is the primary author and who is secondary author). The bookAuthor table has two authorId for the same bookId. One primary author and other secondary author. (Real life scenario where same book have multiple author).

I need to display the names of primary and secondary authors for all the books in BookAuthor table. Like: book id, bookName, primaryauthorid, primaryauthorname, secondaryauthorid, secondaryauthorName row by row. Each row displays one books

I did the following steps: I created the relationships in visual table linking and then I created a group with bookId from bookAuthor and then draged the datafield authorId, authorName twice for primary and secondary author. But the report displays the same author name for the book.

I am in deep trouble due to this.

Can some one help me how to achieve this.

IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 08 Jul 2007 at 3:41pm
I don't think this should be very hard to correct. I'm just concerned about how the tables are linked together. Unfortunately, right now I'm in a coffee house and they are blaring music and everyone around me is talking, so I'm having a tough time focusing on the question. Nonetheless. I'm thinking that all you need to do is drop one copy of the AuthorName field onto the Details section and it should print both authors with no problem. Since that obviously isn't happening for you, then I wonder if possibly the tables are joined in such a way that you are only getting one author per book? I assume that there are two records in the BookAuthor table for each book with each record specifying a different AuthorType? I would put all the fields in the Group Header except for AuthorName and AuthorType. Put these in the Details section.

One thing to do to check that your tables are linked properly is to do a Show SQL Query and then copy and paste the SQL into an Access query and see what the results are. That will tell you if both authors are being associated with each book.

Sorry if I'm totally off base. Hopefully, I'll be in a quieter place next time I check the forum.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 09 Jul 2007 at 11:45am

You only need to have the author name once.  If you want the primary and the secondary to show on the same line, you'll have to do something like this:

1.  Create a second detail section.  Put the author name in this section so that it is NOT under the author name in the first detail section. (We're going to line them up side-by-side.)

2.  Right-click on the author name in this new section and select "Format Object".  Click on the Suppress formula button and enter something like {BookAuthor.AuthorType} <> 'Secondary'.
 
3.  Format the author name in the first detail section the same way except the Suppress formula should be something like {BookAuthor.AuthorType} <> 'Primary'.
 
4.  Open the Section Expert and for the first detail section select "Underlay Following".  For the second detail section make sure that "Suppress Blank Section" is NOT checked.
 
If you want the author's names to appear underneath each other with some text about whether it's the primary or secondary.  Set up one detail line with just one author's name.  Create a formula that looks something like this:  if {BookAuthor.AuthorType} = 'Primary' then 'Primary Author' else 'Secondary Author'.  Use this formula on the report instead of just a text block.
 
-Dell
IP IP Logged
bt_sangram
Newbie
Newbie


Joined: 08 Jul 2007
Location: India
Online Status: Offline
Posts: 5
Quote bt_sangram Replybullet Posted: 09 Jul 2007 at 9:47pm
Hi,

My problem is to display all author Names on one line. Now that may  be on the group header line or single line in Detail section.

When I add one authorName field in detail section, I do get the list of all authors one beneth other but that is not what is required.

I want to create a tabular structure which display a list of all bookNames and their primary, secondary authors.

I also tried creating two formula field and place them in header section.

@primary_auth
if authortype = "primary" then authorname else ""

@secondary_auth
if authortype = "secondary" then authorname else ""

But the report displays only primary authorName and keeps the secondary blank. what i concluded was, may be in  groupHeader section, the  value for authorType is selected once (i.e. primary) and then both the formulae are evaluated using same value for authorType i.e. "primary". Hence the other formula returns blank.

Some one suggested to use formulas that reference the next record (i.e. the Next() function) but I am unable to find and use it.

Sangram
IP IP Logged
bt_sangram
Newbie
Newbie


Joined: 08 Jul 2007
Location: India
Online Status: Offline
Posts: 5
Quote bt_sangram Replybullet Posted: 09 Jul 2007 at 10:02pm
I tried creating two sections and Open the Section Expert and for the first detail section select "Underlay Following".  For the second detail section making sure that "Suppress Blank Section" is NOT checked.

But what result I got was the record are displayed but they dont appear on the same line. They come one line after the other. I need all the author names on the same line.


IP IP Logged
bt_sangram
Newbie
Newbie


Joined: 08 Jul 2007
Location: India
Online Status: Offline
Posts: 5
Quote bt_sangram Replybullet Posted: 09 Jul 2007 at 10:05pm
I tried creating two sections and Open the Section Expert and for the first detail section select "Underlay Following".  For the second detail section making sure that "Suppress Blank Section" is NOT checked.

But what result I got was the record are displayed but they dont appear on the same line. They come one line after the other. I need all the author names on the same line.

IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 10 Jul 2007 at 7:29am
What other information is in the details section?  Are the two sections the same size (they need to be in order for this to work...)?
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.031 seconds.