INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Subreport grouping is incorrect

Subreport grouping is incorrect

(OP)
Hi-
I'm troubleshooting my first Crystal Reports report, working with a main
report that has a subreport that is intended to display all part
information for a given purchase order number. The subreport displays
the individual part records for the purchase order number, and the parts
are meant to be grouped by part ID, then date specified on the part,
then price.

For example, part ID 123 appears on a purchase order 4 times:
1. Date: 1/1/16, Price: 1.00
2. Date: 1/1/16, Price: 1.50
3. Date: 2/3/16, Price: 1.00
4. Date: 2/3/16, Price: 1.00

Using the example, the part should be displayed in 3 groups on the
purchase order, with items 3 and 4 grouped together. Each group should
be assigned an item number. Using the example, following is the desired
result:
Item 1 - 1/1/16 - 1.00
Item 2 - 1/1/16 - 1.50
Item 3 - 2/3/16 - 2.00

Following is what is happening:
Item 1 - 1/1/16, Price: 1.00
Item 2 - 1/1/16, Price: 1.50
Item 3 - 2/3/16, Price: 1.00
Item 4 - 2/3/16, Price: 1.00

The following code is specified in a formula on the main report:

CODE --> Crystal

whileprintingrecords;
stringvar    array polinepart;
datevar      array polinedate;
numbervar    array polineprice;
booleanvar supress := false;
local numbervar x := ubound(polinepart);
local numbervar i;

if not(onfirstrecord) and {PurchaseOrderDetail.PurchaseOrderID} = 

previous({PurchaseOrderDetail.PurchaseOrderID})
then
    (
        for i := 1 to x do
        (
            if 
                polinepart[i] = trim({PurchaseOrderDetail.PartID}) & 

'[]' & trim({PurchaseOrderDetail.PartRevisionID})
                and
                polinedate[i] = {PurchaseOrderDetail.Date}
                and
                polineprice[i] = {PurchaseOrderDetail.Price}
            then
            (
                supress := true;
                exit for;
            )
        )
    )
;

if not supress
then
    (
        redim preserve polinepart[x + 1];
        redim preserve polinedate[x + 1];
        redim preserve polineprice[x + 1];
        
        polinepart[x + 1] := trim({PurchaseOrderDetail.PartID}) & '[]' & 

trim({PurchaseOrderDetail.PartRevisionID});
        polinedate[x + 1] := date({PurchaseOrderDetail.Date});
        polineprice[x + 1] := {PurchaseOrderDetail.Price};
    ) 

The variable 'supress' is used to determine whether or not to display
the next sequential item number for the records returned from the
subreport. Following is the code behind the item number that appears on
the main report:

CODE --> Crystal

whileprintingrecords;
booleanvar supress;
numbervar itemnumber;

if not supress
then itemnumber := itemnumber + 1 

The issue was "resolved" by suppressing the group header on the
subreport, which isn't desirable. The group header contains column
headers for the columns in the subreport, and all but 1 column are text
fields; the other column is a formula field. The group headers should
print once for each group.

As a test, I removed everything in the subreport's group header and
unchecked the Suppress switch on the group header, and again noticed
that the report wasn't grouping. If I suppress the group header, the
report appears to group correctly.

My assumption as to why this is happening is because the code to group
by item number isn't aware of the grouping that is specified on the
subreport. If I'm correct, my plan was to programmatically display group
headers on the subreport, but I don't know where to start to accomplish
this. In the current report setup, I can't see how to employ group
headers without redoing the logic in the report.

Am I on the right track with this? If not, can you tell me where I'm
falling down, or suggest a better approach to accomplish the goal?
Thank you for any input.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close