Printing records which don't exist.

  • Thread starter Thread starter John Baker
  • Start date Start date
J

John Baker

I have a report which often has less than 8 records. However I would like to
always print 8 records even when there are less. The extra records making up
the 8 would appear blank but the solid outline around the fields should
still appear. It may be possible that more than 8 records could exist.

How could I achieve this?

Any help greatly appreciated.

John Baker
 
One way is to use the Format event of the (Detail?) section to set the
report's runtime properties - NextRecord, PrintSection, and MoveLayout - so
that the last record is continually printed until you have 8 done. For the
count, add a text box with these properties:
Control Source =1
Running Sum Over All

Once you are at the last record, set the ForeColor of the controls to
vbWhite so the text does not show, but the outlines do. It's a bit messy,
you'll figure it out if you try.

One side effect is that you are likely to confuse Access with the page
count, e.g. it may say you are not printing "Page 2 of 1".
 
I would use code like the following in the On Page event of the report.
Private Sub Report_Page()
Dim intNumLines As Integer
Dim intLineNum As Integer
Dim intDetailHeight As Integer
Dim intPageHeadHeight As Integer
On Error GoTo Report_Page_Error

intNumLines = 30
intDetailHeight = Me.Section(acDetail).Height
intPageHeadHeight = Me.Section(3).Height
For intLineNum = 1 To intNumLines
Me.CurrentY = (intLineNum - 1) * intDetailHeight + intPageHeadHeight
Me.CurrentX = 0
Me.FontBold = True
Me.FontSize = 14
Me.Print intLineNum 'print the line number
Me.Line (0, intPageHeadHeight + intLineNum * intDetailHeight)- _
Step(Me.Width, 0)
Next

On Error GoTo 0
Exit Sub

Report_Page_Error:
Select Case Err
Case 2462 'no page header
intPageHeadHeight = 0
Resume Next
End Select
MsgBox "Error " & Err.Number & " (" & Err.Description & _
") in procedure Report_Page of VBA Document Report_Report1"

End Sub
 
Back
Top