Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: displaying array string from paramters Post Reply Post New Topic
Author Message
johnwsun
Senior Member
Senior Member


Joined: 28 May 2008
Location: Australia
Online Status: Offline
Posts: 179
Quote johnwsun Replybullet Topic: displaying array string from paramters
     Posted: 03 Mar 2013 at 2:54pm
Hi,
 
I wish to display selection criteria in a report where user would be alble to see what they have selected a couple of locations.
e.g {?locations} has contained 'ALL', ,3, 4, 80, 119 from a parameters pickup list
where selected 'ALL' will populated all records in ALL locations, while selecting 3,4, etc will populate records in individual locations.
 
I have used a formula which I put in the report header
 
select case join({?location})
  case "ALL"
    formula = "All locations"
  case "3","4","44","80","119"
    formula =  "XYZ" + "UWS" + "ABC" + "DEF" + "GS"
 
end select
 
the above not workig at all - only when selcting 'ALL' will work
3,4, 44 etc above are the codes which are passed into report for populating records, how do I assign the actual texts for these codes.
Please advise, thanks in advance.
 
JS
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 04 Mar 2013 at 4:11am
Change your formula to something like this:
 
Because this is in the report header, I would do this as a subreport that will connect to the table that contains the table that has the location description.  The subreport will have the same parameter as the main report.  Inside the subreport, you'll have something like the following formula:
 
Shared StringVar descripts;
If "ALL" in {?location} then descripts := "All Locations"
else
  If OnFirstRecord descripts := {LOCATION.DESCRIPTION}
  else descripts := descripts + ", " + {LOCATION.DESCRIPTION};
descripts
 
Suppress all sections of the subreport except a Report Footer section.  Then place this formula in the (suppressed) details section of the subreport.
 
Create a second formula for displaying the descriptions in the Report Footer.  It will look like this:
 
Shared StringVar descripts
 
This will then display either "All Locations" or a comma-delimited list of the selected location descriptions.
 
There are two reasons why you need a subreport for this:
 
1.  In the main report, you can't concatenate data like you want to do and have it show in the Report Header which processes prior to the report data.
 
2.  If there are any selected locations that do NOT have data in the main report, you still want to show the location as having been selected.  The only way to do this is through a separate query.
 
-Dell
IP IP Logged
johnwsun
Senior Member
Senior Member


Joined: 28 May 2008
Location: Australia
Online Status: Offline
Posts: 179
Quote johnwsun Replybullet Posted: 04 Mar 2013 at 11:23am
Hi Dell,
 
I will try your suggestion; I was trying to do a 'do while' loop last night...but not finished.
 
Thanks,
 
John
 
IP IP Logged
johnwsun
Senior Member
Senior Member


Joined: 28 May 2008
Location: Australia
Online Status: Offline
Posts: 179
Quote johnwsun Replybullet Posted: 04 Mar 2013 at 3:07pm
Hi Dell,
 
I have completed what you have advised:
 
1. in the subreport I have got two tables which show me:
 
code     Head (location description)
 
1          xyz
2          xxx
3          abc
...
...
 
the codes and description have all I  need
2. I created same parameter - locations with the pickup list in the  subreport
3. I constructed the formula as advised:
@get_loc_desc
 
Shared StringVar descripts;
If "ALL" in {?location} then descripts := "All Locations"
else
  If OnFirstRecord then
        descripts := {HEADING.HEAD}
  else descripts := descripts + ", " + {HEADING.HEAD};
descripts
 
4. constructed another formula
@display_loc_desc
Shared StringVar descripts
 
5. Insert the subreport into the main report - report headB section
6. change subreport link - > same parameters as Main report
7. when running, the subreport does not display the locations I selected from location prompts, instead it displays the first, the second, etc., in the list of @display_loc_desc ( when I double checked in the subreport alone, if I de-suprress the detail section, and pull the code and head(location description) fields into the detail section - there are the same locations displaying when running the main report along with the subreport.
Any idea, something I missed out?
Thanks in advance.
 
John
 
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 05 Mar 2013 at 3:38am
Why do you have two tables in the subreport?  You should be able to do it with just the "lookup" table that contains the descriptions of the locations.
 
Also, you created the parameter, but are you using it to filter the data in the subreport?
 
Try unsuppressing a report header section in the subreport and put the parameter there so you can see the value of what is being linked in from the main report.
 
-Dell
IP IP Logged
johnwsun
Senior Member
Senior Member


Joined: 28 May 2008
Location: Australia
Online Status: Offline
Posts: 179
Quote johnwsun Replybullet Posted: 05 Mar 2013 at 2:24pm
Hi Dell,
 
I was origially thinking of using the lookup table, but found I could not directly use it; now I created a view based on that lookup table in the database, and pull the view into the subreport.
Yeh, it works as suggested :-) fantastic !
Thanks a lot!
 
John
 
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