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!

Problem passing global variable between two detail sections

Status
Not open for further replies.
May 1, 2006
8
0
0
US
I am using Crystal Reports for Visual Studio .net 2003.

I have a report that has two detail sections. I am suppressing account numbers that have a type = '1'. The second detail I want to suppress based on the first details account number. I store the first detail's account number in a global variable. The second detail is showing records that are suppressed.

account number type
1 2
2 1
2 2
2 3
3 1
3 1
3 1
3 2

Thanks,

Barry
 
You don't have to use a variable to do this, since the separate detail sections still refer to the same database row. In other words, you can just apply the account number criteria directly to detail_b.

-LB
 
Thank you for your reply.

I am trying to store the account number for DetailA that has not been suppressed (if type is '1' I am suppressing). Then I want to suppress DetaillB accounts that do not match.

In the following example. The first row has a type of '2' so I do not suppress. I print detailA and detailB. The second row has a type of '1' so I need to suppress detailA and DetailB. The third row’s account number is the same as row two’s account number so I want to suppress printing.

I hope this makes more sense. Thanks for your help.

Example Data:
Account number type
1 2
2 1
2 2
2 3
3 1
3 1
3 1
3 2
4 2
4 3
4 3

Expected Results:

Account number type
1 2
4 2
4 3
4 3

 
There is a miscommunication here. The results of one field will always be the same in both detail_a and detail_b--so you must actually be displaying different fields in detail_a and detail_b, OR, you are not actually using detail_a and detail_b, but instead are referring to different detail rows. Please clarify.

-LB
 
Let me try and clafify further,


I am suppressing for detail_a account_numbers that are equal previous account numbers or type = ‘1’.

I want to store detail_a non suppressed account numbers and compare them to detailb records to determine whether to suppress.

I read account number ‘1’ detail_a with a type of ‘2’ I want to store the account number.
For detail_b I compare the account number to the stored account number and print.

I read account number ‘2’ detail_a and it has a ‘1’ in the type so I will suppress it and not store the account number.
For detail_b I compare the account number to the stored account number and suppress it.

I read the next account number ’2‘ detail_a and it is equal to the previous account number so I will suppress it and not store the account number.
For detail_b I compare the account number to the stored account number and suppress it.

I read the next account number ‘2’ detail_a and it is equal to the previous account number so I will suppress it and not store the account number.
For detail_b I compare the account number to the stored account number and suppress it.

......................


I read the next account number ‘4’ detail_a and it is does not equal to the previous account number so I will print it and store the account number.
For detail_b I compare the account number to the stored account number and print it.

I read the next account number ‘4’ detail_a and it is equals to the previous account number so I will not print it and not store the account number.
For detail_b I compare the account number to the stored account number and print it.


Thank You for your help,

Barry
 
Sorry I don't follow this. Maybe you should show an example where you identify the detail_a and detail_b sections along with sample data and then show the expected result, again with the sections identified.

I also think you should explain the context for doing this--there might be a better approach.

-LB
 
What I am trying to do in the enclosed example is if a type is a ‘1’ do not print any of the additional types associated with that account number. If the type is not a ‘1’ print all types associated with the account number.


Example Data:
Account number type
1 2
2 1
2 2
2 3
3 1
3 1
3 1
3 2
4 2
4 3
4 3

Expected Results:

1 2 John Smith detail_a
1 2 aaaaaaaaa detail_b
4 2 Mike Jones detail_a
4 2 ababababa detail_b
4 3 cdcddcdcdc detail_b
4 3 dfasdfasfdf detail_b

detail_a
account_number type global_account_number

suppress formula for detail_a
not onfirstrecord and({table.account_number} = previous {table.account_number}))
or {table.type} = ‘1’

global_account_number formula
global numbervar global_account_number;
global_account_number := {table.account_number};
global_account_number;

detail_b
global_account_number type otherstuff

suppress formula for detail_b
global numbervar global_account_number;
global_account_number <> {table.account_number};
 
You would be better off taking a different approach. First insert a group on {table.account_number} and then create a formula {@has1}:

if {table.type} = '1' then 1

Then go to report->selection formula->GROUP and enter:

sum({@has1},{table.account_number}) = 0

Your approach will not work for several reasons. The account number will always be the same in detail_a and detail_b, regardless of whether detail_a is suppressed. You would also need to use whileprintingrecords to compare between sections.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top