Skip to Content
0

print fixed number of lines in group header

Nov 15, 2016 at 11:09 AM

57

avatar image
Former Member

Hello,

I have to develop a payment voucher in crystal reports 2008. The data is being extracted from JrnlRow table and Chart table. JrnlRow and Chart table are linked by GLAcntNumber as follows:

Chart.GLAcntNumber --> JrnlRow.GLAcntNumber (Join Type = Inner Join)

I defined a group on Chart.Account ID and printed Chart.AccountID and Sum of JrnlRow.Amount in Group Header.

There can be one or more lines printed in group header depending on the number of transactions for a given invoice and vendor (given in the parameter field). What I need to accomplish is to always print eight lines for the group data. For example, if the group header shows three accounts and sum of amount, five extra blank lines need to be displayed. If the group header shows six accounts and sum of amount, two extra lines need to be displayed.

To accomplish this, I right clicked group header and clicked insert section below. This inserted Group Header # 1b. In this way, I inserted up to Group Header # 1h (for up to eight lines max). Then I created a formula isLastRec that has the following code:

if next({Chart.AccountID}) <>{Chart.AccountID} 
then true else false 

I placed this formula in Group Header # 1b, 1c, up to 1h. In the section expert, selected X+2 of Suppress (No Drill-Down) for Header # 1b, 1c, ... 1h and entered:

{@isLastRec} = true

With this setup, I printed a sample voucher that had two account ids and sum amounts. The two lines printed correctly. However, after that, blank lines of all seven headers (1b to 1h) printed. According to my requirement, I need to print six blank lines in this case, because two lines with data have been printed. So, the remaining six blank lines need to be printed.

Regards,

Aziz

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
avatar image
Former Member Nov 16, 2016 at 09:11 AM
0

Thanks.

Finally, I succeeded in accomplishing it as follows:

Moved Chart.AccountID and Sum of JrnlRow.Amount from Group Header to Group Footer (It was needed because I was not getting the value of OnLastRecord in Group Header).

Created a formula field grprecno with the following formula:

WHILEPRINTINGRECORDS;   
GLOBAL NUMBERVAR GroupRecNumber;   
GroupRecNumber := GroupRecNumber + 1;   

Created a formula field mod_record with the following formula:

({@grprecno} Mod 8)

Then I inserted seven Group Footer sections from Group Footer # 1b to Group Footer # 1h and inserted a blank line in each footer. Then in the section expert, entered the following formula for each footer in Suppress (No Drill-Down).

//Group Footer # 1b: Chart.AccountID
If OnLastRecord = true Then
  If {@Mod_Record} <= 1 Then 
      false 
  Else 
      true
Else
  true

//Group Footer # 1c: Chart.AccountID
If OnLastRecord = true Then
  If {@Mod_Record} <= 2 Then 
      false 
  Else 
      true
Else
  true

//Group Footer # 1d: Chart.AccountID
If OnLastRecord = true Then
  If {@Mod_Record} <= 3 Then 
      false 
  Else 
      true
Else
  true

//Group Footer # 1e: Chart.AccountID
If OnLastRecord = true Then
  If {@Mod_Record} <= 4 Then 
      false 
  Else 
      true
Else
  true

//Group Footer # 1f: Chart.AccountID
If OnLastRecord = true Then
  If {@Mod_Record} <= 5 Then 
      false 
  Else 
      true
Else
  true

//Group Footer # 1g: Chart.AccountID
If OnLastRecord = true Then
  If {@Mod_Record} <= 6 Then 
      false 
  Else 
      true
Else
  true

//Group Footer # 1h: Chart.AccountID
If OnLastRecord = true Then
  If {@Mod_Record} <= 7 Then 
      false 
  Else 
      true
Else
  true

Regards,

Aziz

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Hi Aziz,

Good job. I had to create a similar report that had to print a maximum of 6 detail lines per page. If the group had more than 6 the remainder had to continue onto the next page.

I did the same thing you did, create blank sections and hid or showed them depending on how many lines were returned.

Brian

0
Former Member
Brian Dong

Thanks Brian :)

Thank you for sharing the experience.

Regards,

Aziz

0