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

Using Do Loops?

Status
Not open for further replies.

ajhess

Technical User
Jul 27, 2012
18
0
0
US
Hi, I'm using Crystal Reports 2008.
I have data that looks like the table below. What I'm trying to do: for every like 'Guarantor', I would like to create a formula field to tag each 'Source' = "PROFESSIONAL" account with the associated 'Source' = "HOSPITAL" account. I've tired using a "DO" loop as such... hoping that for each guarantor it would cycle backwards to the "HOSPITAL" account and bring in that value

if {Source} = "PROFESSIONAL" then
do previous ({Account}} while {Source} = "PROFESSIONAL"

I'm new to loops/programming in general, I would very much appreciate any ideas or guidance. Thank you!
Andrew

Account__ Source________ Guarantor
1234____ HOSPITAL_______ 1111111
888999__ PROFESSIONAL__ 1111111
777888__ PROFESSIONAL__ 1111111
3456____ HOSPITAL_______ 3333333
111222__ PROFESSIONAL__ 3333333
444555__ PROFESSIONAL__ 3333333
666777__ PROFESSIONAL__ 3333333
6789____ HOSPITAL_______ 5555555
999111__ PROFESSIONAL__ 5555555
777555__ PROFESSIONAL__ 5555555
 
ajhess,

If I understand correctly, you wish to have the Account Number from the "Hospital Record" display for each of the "Professional" with the same Guarantor?

Group 1: Guarantor
- Details: Sorted by Source (Ascending, A-Z)

{@HospitalAcct}
Code:
[blue]WhilePrintingRecords[/blue];
[blue]Shared NumberVar[/blue] HospitalAccount;

[blue]IF[/blue] {Table.Source}="HOSPITAL" [blue]THEN[/blue] HospitalAccount:={Table.Account};

HospitalAccount;

Hope this helps! Cheers!

Mike
---------------------------------------------------------------
"To be alive is to revel in the moments, in the sunrise and the sunset, in the sudden and brief episodes of love and adventure,
in the hours of companionship. It is, most of all, to never be paralyzed by your fears of a future that no one can foretell."
 
Another approach would be to add the table a second time a an alias (table_1), linked on the guarantor field, and limit the Source in the first table to "Professional" and the source in the second to "Hospital" in the selection formula.

-LB
 
Both solutions worked beautifully... thank you, very appreciated!

Andrew
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top