Skip to Content
avatar image
Former Member

print fixed number of lines in group header

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

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

    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

    Add comment
    10|10000 characters needed characters exceeded