[AccessD] Blank Lines in report

A.D.Tejpal adtp at airtelmail.in
Fri Oct 31 00:04:43 CDT 2008


Kaup,

    If you wish to revert to normal printing (no blank rows) subsequent to insertion of blank row after 16th record, revised code in report's module, as given below, should get you the desired results.

    You might like to try it out and confirm the outcome.

Best wishes,
A.D. Tejpal
------------

' Code in report's module
'===============================
' Declarations section
Private RowCount As Long
Private Const RowGrpMinor As Long = 3
Private Const RowGrpMajor As Long = 16
'-----------------------------------------------

Private Sub Detail_Print(Cancel As Integer, _
                                    PrintCount As Integer)
    ' Perform line increment only if the record is
    ' actually going to be printed on this very page
    If Me.Detail.WillContinue = False Then
        RowCount = RowCount + 1
    End If
    
    ' Discontinue insertion of blank rows if
    ' record RowGrpMajor has been crossed
    If RowCount > (RowGrpMajor + _
                (RowCount \ (RowGrpMinor + 1)) + 1) Then
        Me.NextRecord = True
        Me.PrintSection = True
        Exit Sub
    End If
    
    If RowCount Mod (RowGrpMinor + 1) = 0 _
                Or RowCount = (RowGrpMajor + _
                (RowCount \ (RowGrpMinor + 1)) + 1) Then
        Me.NextRecord = False
        Me.PrintSection = False
    Else
        Me.NextRecord = True
        Me.PrintSection = True
    End If
End Sub
'-----------------------------------------------

Private Sub Report_Open(Cancel As Integer)
    RowCount = 0
End Sub
'===============================

  ----- Original Message ----- 
  From: Kaup, Chester 
  To: Access Developers discussion and problem solving 
  Sent: Friday, October 31, 2008 01:01
  Subject: Re: [AccessD] Blank Lines in report


  Thanks for the code however I guess I did not explain the line breaks as well as I could have. This part is correct.

  Apparently, you wish to insert a blank line after every three records up to 15th record and then another blank line after the sixteenth record.

  Here is the change.
  Thereafter there are to be no more blank lines.

  Thanks for your assistance.

  -----Original Message-----
  From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of A.D.Tejpal
  Sent: Thursday, October 30, 2008 2:08 PM
  To: Access Developers discussion and problem solving
  Subject: Re: [AccessD] Blank Lines in report

  Kaup,

      Apparently, you wish to insert a blank line after every three records upto 15th record and then another blank line after the sixteenth record. Thereafter, similar cycle to be repeated from record 17 to 32 and so on.

      Sample code in report's module as given below, should get you the desired results. It would be noted that for incrementing row count variable, detail section's print event has been used instead of the format event. The latter would have led to unwanted increments in case of extra cycle of formatting caused by a calculated text box having [Pages] as part of its expression.

      Check against WillContinue property of detail section is found necessary so as to avoid phantom increment to row count variable at the end of a page.

      The suggested solution has been tested at my end on Access 2003 desktop. You might like to try it out and confirm the outcome.

      Imp:  Please make sure that the setting [Event Procedure] appears on Event tab of properties sheet against report's open event and detail section's print event.

  Best wishes,
  A.D. Tejpal
  ------------

  ' Code in report's module
  '==============================
  ' Declarations section
  Private RowCount As Long
  Private Const RowGrpMinor As Long = 3
  Private Const RowGrpMajor As Long = 16
  '---------------------------------------------

  Private Sub Detail_Print(Cancel As Integer, _
                                      PrintCount As Integer)
      If Me.Detail.WillContinue = False Then
          RowCount = RowCount + 1
      End If

      RowCount = IIf(RowCount <= (RowGrpMajor + _
                    (RowCount \ (RowGrpMinor + 1)) + 1), _
                    RowCount, 1)

      If RowCount Mod (RowGrpMinor + 1) = 0 _
                    Or RowCount = (RowGrpMajor + _
                    (RowCount \ (RowGrpMinor + 1)) + 1) Then
          Me.NextRecord = False
          Me.PrintSection = False
      Else
          Me.NextRecord = True
          Me.PrintSection = True
      End If
  End Sub
  '---------------------------------------------

  Private Sub Report_Open(Cancel As Integer)
      RowCount = 0
  End Sub
  '===============================

    ----- Original Message -----
    From: Kaup, Chester
    To: Access Developers discussion and problem solving
    Sent: Wednesday, October 29, 2008 21:32
    Subject: [AccessD] Blank Lines in report

    I have some data in a table I need to display in a report. The problem is I need a blank line in the report after the 3rd, 6th, 9th, 12th, 15th and 16th record. I found some code in MS article 208696 but that is only for every nth record. The stumbling block is the last interval. Maybe I could put some blank records in the source data?

    Chester Kaup


More information about the AccessD mailing list