ACC2000: How to Print a Constant Number of Lines Per GroupID: Q210350
|
This article describes how to create a constant number of lines per data
group on a report. You can use this method to consistently print 15 lines
per data group, regardless of the actual number of items within the group.
Note that if the group contains more than 15 items, the function used by
this method will not apply.
Microsoft provides programming examples for illustration only, without warranty
either expressed or implied, including, but not limited to, the implied warranties of
merchantability and/or fitness for a particular purpose. This article assumes that you
are familiar with the programming language being demonstrated and the tools used to
create and debug procedures. Microsoft support professionals can help explain the functionality
of a particular procedure, but they will not modify these examples to provide added
functionality or construct procedures to meet your specific needs. If you have limited
programming experience, you may want to contact a Microsoft Certified Solution Provider
or the Microsoft fee-based consulting line at (800) 936-5200. For more information about
Microsoft Certified Solution Providers, please see the following page on the World Wide Web:
http://www.microsoft.com/mcsp/For more information about the support options available from Microsoft, please see the following page on the World Wide Web:
http://www.microsoft.com/support/supportnet/overview/overview.asp
The following steps demonstrate how to create a report in the sample database Northwind.mdb with a constant number of lines per data group. You can use this method in a main report or subreport:
CAUTION: Following the steps in this example will modify the sample
database Northwind.mdb. You may want to back up the Northwind.mdb file
and perform these steps on a copy of the database.
Text box
------------------------------------------------------------------
Name: TotGrp
ControlSource: =Count(*) 'Returns the number of records per group.
Text box
-------------------------
Name: ProductName
ControlSource: [ProductName]
Option Compare Database 'Use database order for string comparisons.
Option Explicit
Global TotCount As Integer
' Call the SetCount() function from the group header section's
' OnPrint property using the syntax: =SetCount(Report)
Function SetCount (R As Report)
TotCount = 0
R![ProductName].Visible = True
End Function
' Call the PrintLines() function from the detail section's OnPrint
' property using the syntax: =PrintLines(Report,[TotGrp]).
Function PrintLines (R As Report, TotGrp)
TotCount = TotCount + 1
If TotCount = TotGrp Then
R.NextRecord = False
ElseIf TotCount <TotGrp And TotCount> 15 Then
R.NextRecord = False
R![ProductName].Visible = False
End If
End Function
Additional query words: preprinted pre-printed fixed
Keywords : kbusage kbdta RptEvent
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: July 6, 1999