Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Multiple primary key throwing me for a loop Post Reply Post New Topic
Page  of 2 Next >>
Author Message
malibu327
Newbie
Newbie
Avatar

Joined: 06 Jan 2009
Location: United States
Online Status: Offline
Posts: 7
Quote malibu327 Replybullet Topic: Multiple primary key throwing me for a loop
     Posted: 06 Jan 2009 at 5:58pm
Hi all,

I have been doing my best to create some CR templates for use in a helpdesk program my company uses.  As this is my first experience with CR and I have no practical experience with databases or writing code, I've been struggling.  I'm not even sure what to search for in these forums, although I have tried with no success to find my own answers.

Hopefully this is an easy one for somebody.

Everything is based on an issue number {IS_ISSUE_NO}.  For the most part I've been able to create a report by merely dragging and dropping a desired field into the report, and I get the data in that field for the corresponding issue number.  Simple enough.

The problem I am having is that one of the fields I want in the report, {ITX_ISSUE_TEXT}, is used for an issue description AND an issue resolution.  There is another field, {ITX_ISSUE_TEXT_TYPE}, that is used as a second primary key (which seems counter-intuitive to me).  {ITX_ISSUE_TEXT_TYPE} is set to 1 for a description, and 2 for a resolution.

I only want resolution data in my report.  However, if I merely drag {ITX_ISSUE_TEXT} in, it only yields description data.  Can someone assist me with a formula that I can drag into the report that will give me the {ITX_ISSUE_TEXT} data where the {ITX_ISSUE_TEXT_TYPE} primary key is 2?  It seems simple, but yet it eludes me.

Any assistance would be GREATLY appreciated...  Time to buy the book!

Thanks,

Craig
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 06 Jan 2009 at 9:30pm
Hey Craig,
 
This shouldn't be too tough to get working. You will need to create a formula and drag and drop that formula onto your report. I suggest something like this (I got confused about which fields should be displayed, so you can clean this part up).
IF {ITX_ISSUE_TEXT_TYPE}=1 THEN
    {ITX_ISSUE_TEXT}
ELSE
    {ITX_ISSUE_???};
Try this and see how it works. If you get the book, I have three chapters in covering formulas, but you'll want to look at Chapter 5 first b/c it shows you the ins and outs of the formula workshop.
 
You can find out more about my books at Amazon.com or reading the Crystal Reports eBooks online.
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
malibu327
Newbie
Newbie
Avatar

Joined: 06 Jan 2009
Location: United States
Online Status: Offline
Posts: 7
Quote malibu327 Replybullet Posted: 07 Jan 2009 at 6:30am
Hi Brian,

Thanks for the reply.  The formula you posted is basically what I have been trying to no avail.  Here's what I know so far:

-- For every record, the table {ISSUE_TEXT} will have two entries.

-- The table {ISSUE_TEXT} uses {ISSUE_TEXT.ITX_ISSUE_NO} as a primary key, and it also uses {ISSUE_TEXT.ITX_ISSUE_TEXT_TYPE} as a primary key.  {ITX_ISSUE_NO} is linked to {ISSUES.IS_ISSUE_NO}.

-- The result of this is that the two entries for each record both have the same value for {ITX_ISSUE_NO} but different values for {ISSUE_TEXT.ITX_ISSUE_TEXT_TYPE}.

-- If I delete the entry with {ISSUE_TEXT.ITX_ISSUE_TEXT_TYPE}=1, the formula gives me what I want.  However, the next time I open the record, the database recreates the entry with {ISSUE_TEXT.ITX_ISSUE_TEXT_TYPE}=1.

It seems like the formula is never even looking at the second entry, as if it is assuming it's done after finding one entry with a matching primary key value.  If this is the case, is there a way to make it keep looking?

I hope my question makes sense.

Thanks again for your help,

Craig

P.S. This is Crystal Reports 10 if it matters.


Edited by malibu327 - 07 Jan 2009 at 6:31am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 07 Jan 2009 at 7:35am

If I understand your problem I think you might be overcomplicating your solution. Is this correct...

You have 2 tables, ISSUES and ISSUES_TEXT which are joined on IS_ISSUE_NO.
The ISSUES_TEXT table always has 2 rows per IS_ISSUE_NO, one with ITX_ISSUE_TEXT_TYPE=1 and one with ITX_ISSUE_TEXT_TYPE=2. You only want to display rows where ITX_ISSUE_TEXT_TYPE=2.
Don't deal with this in a formula but rather use the select expert to only include the records that you want:
{ISSUE_TEXT.ITX_ISSUE_TEXT_TYPE}= 2


Edited by DBlank - 07 Jan 2009 at 7:35am
IP IP Logged
malibu327
Newbie
Newbie
Avatar

Joined: 06 Jan 2009
Location: United States
Online Status: Offline
Posts: 7
Quote malibu327 Replybullet Posted: 07 Jan 2009 at 10:26am
DBlank,

You are right on with what I have and what I want.  And overcomplicating seems to be my speciality! LOL

So, rather than referencing the formula I've created, I simply dragged {ISSUE_TEXT.ITX_ISSUE_TEXT} into the report, right clicked it, chose "Select Expert" and told it {ISSUE_TEXT.ITX_ISSUE_TEXT_TYPE}=2.

I still am experiencing the same problem. Confused

FWIW, if I delete the row where {ISSUE_TEXT.ITX_ISSUE_TEXT_TYPE}=1, I get the result I want.  The application sticks it right back in though when it saves the record.  So, I feel confident that the presence of the first row is the cause of the symptom I am reporting.  However, I don't know what to fix!

Something I just noticed is that CR identifies the indexes of this table in a way that seems odd to me.  According to the index legend, I have 1 1st index, 1 2nd index, and 3 3rd indexes.  The 1st index is also a 3rd?????

I can't upload a screen cap image but can provide one to anyone interested in seeing a screen cap from where I link the tables.

I have a message in to the support guy for the application as well.  I'm stumped.

Thanks again,

Craig
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 07 Jan 2009 at 12:26pm
This seems quite odd to me. Is this a SQL database?
If so, can you create a view to inner join the 2 tables and only select the records from ISSUE_TEXT where {ISSUE_TEXT.ITX_ISSUE_TEXT_TYPE}= 2? You can browse that data to see if it is all good and then use the view for your report instead of the 2 tables.
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 07 Jan 2009 at 1:13pm
I thought I understood the question, but reading through what CR is doing doesn't make sense (a third index???). So what about taking a different approach... Let's assume that you can't get rid of the record equaling 1 and it is always there. Just suppress the records you don't want printed. On the Details section, use a conditional formula for the Suppress property and set it to
{ISSUE_TEXT.ITX_ISSUE_TEXT_TYPE}= 1
That effectively hides the records that don't equal 2. Will that work?


Edited by BrianBischof - 07 Jan 2009 at 1:14pm
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
malibu327
Newbie
Newbie
Avatar

Joined: 06 Jan 2009
Location: United States
Online Status: Offline
Posts: 7
Quote malibu327 Replybullet Posted: 07 Jan 2009 at 3:03pm
Well, the suppression trick was a step in the right direction... whatever direction that is!  In the CR 10 preview tab, it now works.  However, when you run a report from the application, it launches the CR viewer application (the one that gets installed with CRRedist2005_x86.msi) and this field is still blank in the report.

I don't know if I'm in over my head or if I just have really bad luck... ?  Why the difference from one viewer to another?
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 07 Jan 2009 at 7:59pm
This is bad luck. I'm guessing that there might be a versioning issue between the two. Are all the other fields okay? Are you showing the actual field on the report or a formula? If its a formula,what if you change it around some, will that make something appear? Are you using VS 2005? Do you have the latest service packs so its up to date with the latest version of CR XI?
 
Lots, of questions, but since it is acting weird, its a matter of debugging it to see what is causing the difference between the two.
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
malibu327
Newbie
Newbie
Avatar

Joined: 06 Jan 2009
Location: United States
Online Status: Offline
Posts: 7
Quote malibu327 Replybullet Posted: 08 Jan 2009 at 6:55am
Originally posted by BrianBischof

This is bad luck. I'm guessing that there might be a versioning issue between the two. Are all the other fields okay? Are you showing the actual field on the report or a formula? If its a formula,what if you change it around some, will that make something appear? Are you using VS 2005? Do you have the latest service packs so its up to date with the latest version of CR XI?
 
Lots, of questions, but since it is acting weird, its a matter of debugging it to see what is causing the difference between the two.


All other fields are OK.  I am displaying the actual field and suppressing the unwanted records as you suggested a couple posts ago.  I had been working with a formula up until that suggestion and tweaked it every way I could think of with no success.

I just installed SP 6 which was the newest one I saw on the Business Objects support site.  Opened, tweaked a background color slightly, and resaved the report.  It still works in the previewer in the CR application itself but not in the external viewer that my helpdesk software launches to view the report.

Is there a different viewer I could install?  I still think that there's something weird about this database table having three primary keys (yes, it really does have three primary keys) but I think I'm one step past that now.
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