Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing results to a subReport

Status
Not open for further replies.

Viscount

IS-IT--Management
Oct 10, 2003
85
GB
This is doing my head in...

I have a main report which has parameter - ?age - when this is entered it pulls out records that match the paticular age (not surprising) - however as the information is being going to used for a study a set of record numbers that need to be returned have been included.

To do this I have used an IF statement within the supress section of the details section:

e.g.

IF age = 8 then not(recordnumber = [1,2,3,4,5]) else
IF age = 11 then not(recordnumber = [3,4,5,6,7])

etc...

What I want to do is create a sub-report based on the final result - which includes an ID number - which will give the address for that record.

It seems really simple and I cannot understand why I have not managed to get my head round this.

I have tried to create a sub-report linked by the ID - it give me a parameter but it does not take the results and it seems not to be linked in the slightest but acts more like a seperate report. If I enter an id number it will return the address - regardless if that record was included in the main report at all..!

I have also tried grouping the ID in both the main report and the sub-report - but for some reason when I come to link the 2 it does not give me the option to link on that group (?!??!?!)

What am I doing wrong...?
 
Consider posting technical information when requesting technical assistance, specifically, your version of Crystal, example data, and expected output.

Often times subreports are created when they shouldn't be, and there are many fine architects lurking hereabouts, so they just might have something to add.

As for your subreport not linking correctly, presumably you've set the link when you placed it, perhaps something changed it, so check the record selection formula in the subreport, it must reflect the linking you set.

-k
 
Thanks.

CR ver 9

Main Table:

This information comes from 2 tables from SQL2000

ID Name Age Info

1 Bob 8 abc
2 Jon 9 abc
3 Bill 10 def
4 Sue 11 xyz
5 Nic 8 ghi

Paramater = Age

Results

Age = 8

ID Name Age Info Record Number

1 Bob 8 abc 1
5 Nic 8 ghi 2

In addition to this the recordnumber requested will apply

Recordnumber requested = 2

Result that is actuall displayed

ID Name Age Info Record Number

5 Nic 8 ghi 2

What I want to do is after this create a sub-report (as I want to keep the different elements seperate) for the contact details.

Eg...

ID Name Add1 Add2 Add3 Add4 Postcode

5 Nic This is where I Live

All this information comes from the one table already used in the main part.

Hope that this gives a clearer picture.

Vis.
 
To do this I have used an IF statement within the supress section of the details section:

e.g.

IF age = 8 then not(recordnumber = [1,2,3,4,5]) else
IF age = 11 then not(recordnumber = [3,4,5,6,7])



I do not understand this suppress formula...especially as it applies to your example.

Recordnumber is not really a meaningful term as far as the user is concerned...

ID Name Age Info Record Number

1 Bob 8 abc 1
5 Nic 8 ghi 2

In addition to this the recordnumber requested will apply

Recordnumber requested = 2

Result that is actuall displayed

ID Name Age Info Record Number

5 Nic 8 ghi 2


Applying your first formula both values for Age = 8 should be shown since they are recordnumbers 1 and 2 and they are both is the range of this part of the formula

IF age = 8 then not(recordnumber = [1,2,3,4,5])

secondly...

What I want to do is after this create a sub-report (as I want to keep the different elements seperate) for the contact details.

Eg...

ID Name Add1 Add2 Add3 Add4 Postcode

5 Nic This is where I Live

All this information comes from the one table already used in the main part.


If this information is already available....there is no need for there to be a subreport....if this is to be displayed in the same section as the rest of the ID info then just place the fields there...if it is to be placed as a summary later on just save the details in a variable array for later printing....no need for a subreport and your report will run faster as a result.




Jim Broadbent

The quality of the answer is directly proportional to the quality of the problem statement!
 
OkDokey...

Part 1 - The Recordnumber is a check for me to ensure that the correct numbered record is returned - it also means that should a record be disaqualified as not being suitable for the study I can move to the next - slightly manual but it works and it is not huge numbers.

Part 2 - The fact that there were not 2 final results - that was my fault by using 2 examples - under normal circumstances both results would have been returned.

Part 3 - yes the information is already available and it cannot be added to the general details section as it is not necessary at this time - however the variable array sounds quite interesting.

The next question - and I am going to try to find out the answer - what is a variable array and where does one shove it..?

Thanking You

I do feel better now..!
 
well first things first

What version of Crystal Reports are you using??

Also...I would be careful about using the term "recordnumber" I don't think you mean it as described by Crystal...which is the order that the records are brought back from the database...I don't see how you can predict in advance what will or will not be at a certain place in the database

If you are using CR 8 or higher you can use arrays properly...version 7 has arrays but they are very limited.

they are defined by

StringVar Array address := ["","",""];

this is a string array with 3 elements in it

Jim Broadbent

The quality of the answer is directly proportional to the quality of the problem statement!
 
Jim,

Thanks for your reply.

I am using CR9.

I think that I am being really dumb...!

I could easily add the address fields to the existing data - but I do not want to do that. Hence my interest in the var array. I wish to use the main report as a summary that can be used.

I have got a list of people that I want to use. I was hoping, to an unexperienced Crystal user - this sounds simple, to have a seperate tab which I could use as adress labels, and another tab which could be used as covering letters with information taken from the one master list - the main report. I would also be using the main report as a summary sheet to ensure that these people are suitable for the study.

Perhaps I am doing this the wrong way round.

Should I be putting all the information into the main report and then having sumarries for each of the section that I require..?

Thanks.

Vis.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top