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

Custom Print Order in Crystal Reports

Status
Not open for further replies.

kebbusobj

Programmer
Jul 17, 2008
29
US
Hello,

To meet a report requirement, I have created a formula to derive a custom print order for the records in a Crystal Report. It is two-colum report, so the multi-column formatting option is being used in this case, and the printing direction is Accross then Down (to display the records in the same manner they are today outside of Crystal Reports.)

Furthermore, the report is grouped. So, in other words, for each group, the detail records print in two columns in an Accross then Down direction. The report that is written today outside of CR takes the average number of records for each group and displays them in the columns. If the average result is an odd number, then the left column will have one more record than the right column, appearing at the bottom of the left column.

Lastly, each record has an associated, predetermined PageNumber and PrintOrder stored in the database as a field.

The problem that I am running into is how to get the records for each group to appear in two columns, on the right page and in the right sort order, as defined in the database record.

So far, this is what I have been able to accomplish on my own:

1. Created Group "PageNumber" as Group 1, with ascending sort order.

2. Created Group "Description" as Group 2, with ascending sort order. This group is based on a field in the database that categorizes the detail records into groups, and it is the group heading that appears above each detail section.

3. Created a Count Summary on the description field that appears in the detail section and placed in tin the Group Footer Section.

4. Created the following formula "AvgNoRecords":

Round(Count({detailtable.description}, {grouptable.description})/2)

5. Created the following formulas for a manual Running Total scenario:

a.Formula InitPrintOrder (placed in Group Header 2):
WhilePrintingRecords;
NumbverVar PrintOrder:=1;

b.Formula PrintOrderRunningTotal (Placed in Detail Section):
WhilePrintingRecords;
NumberVar PrintOrder;
NumberVar AvgRecords:={@AvgNoRecords};

If {tablename.printorder} = 1
Then PrintOrder
Else If {tablename.printorder} = AvgRecords + 1
Then PrintOrder:=2
Else PrintOrder:=PrintOrder + 2;

c.FormulaPrintOrder:
WhilePrintingRecords;
NumberVar PrintOrder;

This is what I have accomplished thus far. When I go to choose my formula "PrintOrder" as the new Record Sort Order, the formula does not appear in the selection list for me to choose. I AM SURE this is directly related to the evaluation time of my formulas; however, the report errors out whenever I try to change my formulas to evaluate WhileReadingRecords or when I try to change my formulas to EvaluateAfter({@AvgNoRecords}).

Also, I have tried creating manual columns, without using the multi-column formatting option, by placing the detail field twice, side-by-side, within text fields in the detail section, and suppressing embedded blank lines for the text boxes, but this does not display properly.

If any of you might know of a way to accomplish this task, I would greatly appreciate your help.

Thank you!
KB

P.S.
Here's the current print order, along with the desired print results:

Current Print Order: Desired Print Order:
(Page 1)
GroupName GroupName
1 2 1 5
3 4 2 6
5 6 3 7
7 4


(Page 2)
GroupName GroupName
1 2 1 5
3 4 2 6
5 6 3 7
7 4


 
I'm sorry. I realize that the last part might be a little difficult to understand, so please allow me to restate.

The current sort order and desired sort order results are as follows:

Current Sort Order:

GroupName
1 2
3 4
5 6
7

GroupName
1 2
3 4
5 6
7


Desired Sort Order:

(Page 1)
GroupName
1 5
2 6
4 7
5

(Page 2)
GroupName
1 5
2 6
4 7
5
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top