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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple loop question

Status
Not open for further replies.

leveetated

Programmer
Jan 24, 2008
46
US
CR 2008

Hello all,

I can't seem to find this covered in another thread & I feel silly asking it, but here goes:

I simply want to loop through all the values for a given field before jumping to the group footer. Like so:

Value 1
Value 2
Value 3

But it will print Value 1, then the group 2 footer, than Value 2, then group 2 footer again, etc. etc.

I thought I could just plop it in the Details field to complete the loop but have found that's not how it works.

I can't use a subreport, and I can't group on this field (it's a "Memo" field).

Any suggestions, experts..? With many thanks

Lee.
 
Are these values in different fields in the same record or are they in different records? How many possible values can there be? Is it limited to 3 or could there be more?

-Dell

A computer only does what you actually told it to do - not what you thought you told it to do.
 
Crystal has a 'flow', a fixed cycle that you have to slot your own code into. It isn't a full programing language: that's the price you pay for a software tool that can be used to produced a nice-looking report very quickly.

You can collect and store values using variables. Does that help?

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 2008 with SQL and Windows XP [yinyang]
 
Thank you Madawc for that perspective - it does help.

hilfy: this is one field that is shared among all records; I simply want to display its value for each record and I can't group on it, and I can't (apparently) use a subreport to show all the values for this field.

Madawc, should be Googling for array examples in CR 2008? Or were you implying a different approach with you said "you can collection and store values using variables"?

With thanks,

Lee.
 
It sounds like your grouping is at fault. This is hard to troubleshoot, since you are only referencing abstractions. I think it would help if you identified the fields you are grouping on for Group #1 and Group #2 and if you showed actual values, and label all.

Or is the issue that you want to force all values to appear in a group even if no records corresponding to that value appear in the group?

-LB
 
I want all values to appear. The field (publisher) isn't offered to me as an option in the "Insert Group" feature, presumably because it's a "Memo" field type.

Here's what I want to do: first, list all publishers for a publication:

Random House
W.W. Norton
Hyperion
Random House
Prentice Hall

Then, list the rest of the publication information for the books:

John Smith
"The Velveteen Rabbit"
Published 1900

Annie Johnson
"How to Drive a Car"
Published 2010

etc. etc.

Is there a way to loop through all the publishers before displaying the rest of the information for the books?

Thank you,

Lee.
 
Use SEARCH here for Array examples, if you need them.

To list first publishers and then books, I think you need a subreport or a crosstab for the publishers.

If you were willing to show the publishers last, you might collect their details in a large 'string' field. But a subreport would be easier to code and maintain.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 2008 with SQL and Windows XP [yinyang]
 
I've not had success with a subreport approach, because I need ALL publishers for a given set of books, and the main report passes the subreport only one record ID (not an array of all record IDs) so I only get one publisher when I run the subreport.

Am I doing this incorrectly? Is there another way to link a subreport to the main report that would display all of the set's publishers?

I will also look into crosstabs - this is new to me.

With thanks,

Lee.
 
Please reread my post and respond by labeling all fields and showing what your data looks like if you place the fields in the detail section. Also identify the fields you are grouping on and include them in your detail level sample. Show a sample that includes multiple rows that would be returned.

-LB
 
What I meant by 'subreport' was a single subreport in the report header which would do a separate access of the data.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 2008 with SQL and Windows XP [yinyang]
 
Thank you lbass and Madawc. lbass, I'll do my best to show you what I have now:

DETAILS SECTION
---------------
Code:
{Publications.PublisherName}


GROUP 2 FOOTER (grouped on Publications.ID)
---------------
Code:
{Publications.AuthorName}
{Publications.Title}
{Publications.PubDate}

GROUP 1 FOOTER (grouped on Contracts.ID)
---------------
Code:
(Lots of straight text here; legalese mumbo jumbo)



SAMPLE DATA

Code:
(Details section)

Random House
W.W. Norton
Hyperion
Random House
Prentice Hall

----

(Group 2 footer section)
John Smith
"The Velveteen Rabbit"
Published 1900

Annie Johnson
"How to Drive a Car"
Published 2010

Steve Martin
"Cruel Shoes"
Published 1978

John Johnson
"On the South Side"
Published 2009

Sherry Bartlett
"So You Want to Be a Teacher"
Published 1985

----
(Group 1 footer section)
Intellectual Property
A. Intellectual Property Rights
etc. etc.



The publishers must appear before the publications. Because of all the legal text, the section ordering is rigid.

The way it is now, only the first publisher appears in either any group header I create (no matter how I group it) or in the Details section. The report does loop through each publication correctly in Group 2.

With many, many thanks,

Lee.
 
What you are showing makes no sense. You seem to be showing multiple detail records only for the first instance of Group #2 and then no detail records for later instances. Are you suppressing the details conditionally?

Please show a second sample that indicates how you WANT the above data to appear in your report.

-LB
 
My mistake - the sample data above is how I want it to be shown. What actually happens in the report:

Code:
(Details section)

Random House

----

(Group 2 footer section)
John Smith
"The Velveteen Rabbit"
Published 1900

Annie Johnson
"How to Drive a Car"
Published 2010

Steve Martin
"Cruel Shoes"
Published 1978

John Johnson
"On the South Side"
Published 2009

Sherry Bartlett
"So You Want to Be a Teacher"
Published 1985

----
(Group 1 footer section)
Intellectual Property
A. Intellectual Property Rights
etc. etc.

Nothing is being conditionally suppressed in any group or the details section.

Again my apologies, I was concentrating on what I was wishing for a bit too much, instead of what I'm dealing with!

 
Please do as I requested earlier, as this still doesn't make sense to me. Lay out the following fields in the detail section and show multiple rows-- so I can see how the data relates to each other:

ContractID PublicationsId PublisherName Author Title PublishingDate

Please sort in this order (you might not be able to sort by PublisherName, but sort using the others) and show a sample with more than one publisher. Then report back with the resulting sample.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top