Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: duplicating fields Post Reply Post New Topic
Page  of 2 Next >>
Author Message
swilleyk
Newbie
Newbie
Avatar

Joined: 25 Oct 2011
Location: United States
Online Status: Offline
Posts: 18
Quote swilleyk Replybullet Topic: duplicating fields
    Posted: 25 Oct 2011 at 8:43am
I am working off of an application for university where students apply online and then the information is sent to a datatel database on sql server 2008. The problem I am getting is when I am trying to display some of the information is that there are fields like honors that the applicant can enter multiple fields into. When I am trying to display this information cyrstal creates a new report every time there is a new honors field.

Does anyone know of a way to get the field to display on one section. The name of the field is {Datatel_honorExtensionBase.Datatel_name}, and I can not see where it is assigning a different name for each instance of the honors. It attaches the honors to an application id, then distinguishes each field by a key value.

Sounds very confusing, I know, but it has been driving my mad for the past two days trying to see how to get this field to display all at once instead of creating a new instance every time.
Thanks
Kevin

IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 26 Oct 2011 at 3:46am

i think when you say a 'it displays a new report' you mean it shows duplicates rows for the student. This is likely happening becuase your 'honors' table stores 1 row per honor per student. When you join that to the student table it will create as many 'student' rows as there honors for that student (conversely unless you outer join the tables it will omit students that have no honor records).

usually people handle this by grouping on the primary key of the student record (student id) and hiding the details. If you are trying to show all of the honors in 1 row you will need to use shared variable formulas to read the rows and create one string that can be displayed in the group footer.
IP IP Logged
swilleyk
Newbie
Newbie
Avatar

Joined: 25 Oct 2011
Location: United States
Online Status: Offline
Posts: 18
Quote swilleyk Replybullet Posted: 27 Oct 2011 at 3:40am
I am not sure if I understand using the shared variable.

I am a semi newbie to this so I am trying to remember stuff I haven't done in a couple of years.

Basically I need to figure out how to loop through the record and pull out the information to display per person.

So if one person only has one honor, but the next has four, I need to get it to print with the person and not produce a second or third report to display the next honor.

Thanks

IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 27 Oct 2011 at 4:11am
there are a ton of examples of concantenating rows of data into a single string uising formulas wiwh shared stringvar.
here is one link
 
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 27 Oct 2011 at 4:17am
As DBlank mention, if you are grouping on the application id(let's say).
The honors are tied to that value, which is why I am using it, then your data would like:
id1, honor1
id2, honor1
id2, honor2
etc.
 
since you don't want to see the multiple rows, you can create a formula like:
shared stringvar honors := honors +", "+ {table.honor};
 
place this in the detail section and suppress(hide) the section.  Now the formula will accumulate all the honors associated with the id.
 
In the group header you would want a formula like:
shared stringvar honors := ""
 
so that you are only gathering the honors of the id
 
In the group footer you would want something like:
shared stringvar honors;
honors
 
this will display the resulting string (if there is one)
 
All of this is what DBlank was meant when he said: "usually people handle this by grouping on the primary key of the student record (student id) and hiding the details. If you are trying to show all of the honors in 1 row you will need to use shared variable formulas to read the rows and create one string that can be displayed in the group footer."
 
As for the left join, I agree, that it is the wise thing to do for the reason mentioned.
 
HTH
IP IP Logged
swilleyk
Newbie
Newbie
Avatar

Joined: 25 Oct 2011
Location: United States
Online Status: Offline
Posts: 18
Quote swilleyk Replybullet Posted: 28 Oct 2011 at 2:55am
Thanks for the replies - I your suggestion and it worked. The problem I am having now is that there are multiple fields that I am using these formulas for and is is now duplicating the names in each display.

Extracurricular Activities and Interests     , Key Club ‑ President, Key Club ‑

President, FBLA, FBLA, Volleyball, Volleyball

 

Honors     , Capital District Key Club Distinguished Officer, My Neighbor's Foundation Award, Capital District Key Club Distinguished Officer, My Neighbor's Foundation Award, Capital District Key Club Distinguished Officer, My Neighbor's Foundation Award

Is there a way to keep these fields from doing this?

Thanks for all the help so far.



IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 28 Oct 2011 at 11:39am
create a different shared variable for each field.  Increment the field as appropriate.  So while you might increment all the variables in 1 formula (and reset them in 1) you would have multiple lines for the increment, and multiple formulas for display (one per variable).
 
HTH
IP IP Logged
swilleyk
Newbie
Newbie
Avatar

Joined: 25 Oct 2011
Location: United States
Online Status: Offline
Posts: 18
Quote swilleyk Replybullet Posted: 01 Nov 2011 at 3:03am
Ok this is what I have
(Reset)
whileprintingrecords;
stringvar x;
stringvar y;
stringvar z;
if not inrepeatedgroupheader then
x := "";
y := "";
z := "";
(Accum)
whileprintingrecords;
stringvar x := x + {Datatel_honorExtensionBase.Datatel_name} + ",  ";
stringvar y := y + {Datatel_workexperienceExtensionBase.Datatel_name} + ",  ";
stringvar z := z + {@curricname} + ",  ";

I have seperate displays for each one.

Still getting the repeated displays for the honors, work experience and extra curric.


IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 01 Nov 2011 at 10:44am
sorry misunderstood, thought that there were dupes between the different headings.  So, just looking at extracurricular, there are dupes, one would think that the most likely reason for this is that in a join, there is a result of 2 records...so how to get around it?
 
what i would try is:
in the reset, set the value to ", " instead of "".  Then in the accum part add/change:
if instr(x, ", " + {table.field} + ", ") = 0 then
  x := x + {table.field} + ", ";
 
 
this will only allow 1 occurrance of any selection to be in your result string.
 
HTH
IP IP Logged
swilleyk
Newbie
Newbie
Avatar

Joined: 25 Oct 2011
Location: United States
Online Status: Offline
Posts: 18
Quote swilleyk Replybullet Posted: 02 Nov 2011 at 6:12am
I keep getting an error
"The ) is missing" and points to the first x.

Thanks
Kevin
IP IP Logged
Page  of 2 Next >>
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.016 seconds.