Can I Move fields in a Crystal Report to another p

2019-01-27 05:33发布

问题:

I am generating an invoice for various clients. Some clients have a sales allowance. For those clients I want to display an extra sales allowance unit and total cost column.

If any maximum sales cost total is = 0 I want to move the fields to the left and display the sales allowance on the right side

When the client has sales allowance

------------------Headings extend all the way across the report-----------------------------

Description   Qty    UOW      Client Unit Cost   Client Cost    Sales Unit Cost   Sales Cost
============================================================================================
Something       5   Each                $11.00        $55.00              $5.00       $25.00
More Stuff      2   Each                $20.00        $40.00              $5.00       $10.00
============================================================================================
Totals                                                $55.00                          $35.00

When the client does not have sales allowance

------------------Headings extend all the way across the report-----------------------------

Description                                   Qty    UOW      Client Unit Cost   Client Cost
============================================================================================
Something                                       5   Each                $11.00        $55.00
More Stuff                                      2   Each                $20.00        $40.00
============================================================================================
Totals                                                                                $95.00

The goal is to put this functionality into a single report rather than having to know which report to run for which client if and when they get a sales allowance.

I know we can supress fields and when I tried to incorporate that I got whitespace on either the right of middle depending on where I placed the fields and the result was not acceptable. Is there a way to move a field to a different LEFT position when conditions are met? This would be report wide, not evalutated on each detail record.

回答1:

It would be easier if you create two header sections and two detail sections with the fields and headers that you want in each. Suppress the relevant header/detail section based on the presence of a value in the sales-allowance field (Isnull({table.sales_allowance}). If this can't be determined, use a parameter field to drive the suppression formulae.

** edit **

the report will have two header sections (HA & HB) and two detail sections (DA & DB). HA & DA work in combination, as do HB & DB. Use the 'A' set for customers with a sales allowance; use the 'B' set for customers without. Add the relevant fields to each section and header; space accordingly.

Set the suppression formula for HA & DA to:

//suppress section if there IS NOT a sales allowance
Not(Isnull({table.sales_allowance}))

Set the suppression formula for HB & DB to:

//suppress section if there IS a sales allowance
Isnull({table.sales_allowance})

You do NOT need to suppress any individual fields with this approach, thus eliminating the spacing issue.

** edit ** while crystal report objects do have X (left), Y (top), width, and height properties, only X and width support conditional formulae (CF). you could move a field by setting the conditional formula of a field's X property to another value.

this approach would be harder to maintain, however. each field's CF would need to 'remember' two positions: visible and hidden. moreover, if another field was added in the future, each 'moveable' field would need to be reviewed to ensure that the positioning in its CF is accurate.