[AccessD] Blank Lines in report

Kaup, Chester Chester_Kaup at kindermorgan.com
Wed Nov 19 14:30:50 CST 2008


Here is the code I ended up with to get a blank row after certain row numbers. Works good on a one page report. I have not pursued it any further.

Option Compare Database
Option Explicit

' Declarations section
Private RowCount As Long
'---------------------------------------------

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

   If RowCount = 4 Or RowCount = 8 Or RowCount = 12 Or RowCount = 16 Or RowCount = 20 Or RowCount = 22 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: 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
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com





More information about the AccessD mailing list