A subreport with four 'across then down' columns is by far the easiest
solution, but it can be done in a single report by manipulating the position
of the controls at runtime. Here's the module for a report I once produced
to illustrate this. The report lists the occupants of each address across a
single line, wrapping to the next line after every fourth occupant. Exactly
he same result was produced much more simply by means of a subreport, however:
Option Compare Database
Option Explicit
Const FP_ORIGIN = 3315 'original position of FP control
Const FN_ORIGIN = 3576 'original position of FirstName control
Const OFFSET = 1440 'distance controls to be moved to the
'right (one inch in Twips )
Const COLUMN_COUNT = 4 ' number of columns for occupants
' declare module level variables
Dim lngAddressID As Long
Dim n As Integer, i As Integer
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim intOccupants As Integer
' get number of occupants at current address
intOccupants = DCount("*", "People", "AddressID = " & Me.AddressID)
' increment count of occupants in module level variable
i = i + 1
' if first occupant print FP and FirstName at start postion
If n = 0 Then
Me.FP.Left = FP_ORIGIN
Me.FirstName.Left = FN_ORIGIN
' move print location to next line if only one occupant
MoveLayout = (i = intOccupants)
Else
' move FP and FirstName controls one inch to right
Me.FP.Left = FP_ORIGIN + (OFFSET * n)
Me.FirstName.Left = FN_ORIGIN + (OFFSET * n)
' if this is not last occupant for current address then
' don't move print location to next line
If AddressID = lngAddressID And i < intOccupants Then
MoveLayout = False
End If
' if this is fourth occupant printed on this line then
' move print location to next line
If i Mod COLUMN_COUNT = 0 Then
n = -1
MoveLayout = True
End If
End If
' increment count of occupants printed on current line
' in module level variable. NB count is zero-based
n = n + 1
' assign current AddressID to module level variable
lngAddressID = Me.AddressID
End Sub
Private Sub GroupHeader1_Format(Cancel As Integer, FormatCount As Integer)
' don't move print location to next line so that
' first detail (occupant) prints on same line as
' group header
MoveLayout = False
' intialize module level variables to zero for start of
' occupants list for new address
n = 0
i = 0
End Sub
Ken Sheridan
Stafford, England