Skipping lines in reports

  • Thread starter Thread starter LCalaway
  • Start date Start date
L

LCalaway

I am trying to write a report that inserts a blank line after printing five
lines of data. Microsoft had a Knowledge Base article explaining how this
is done, but I cannot find it now.

Does anyone know the correct reference or does anyone have a solution?
Thank you.
LCalaway
 
Good evening

The following code will do the trick for you.

Best Regards

Maurice St-Cyr
Micro Systems Consultants, Inc.


Dim cLines As Integer
Const cMaxLine = 5

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

If cLines Mod (cMaxLine + 1) = 0 Then
Me.NextRecord = False
Me.PrintSection = False
End If
cLines = cLines + 1

End Sub
 
Hi Maurice -
I copied the code you supplied to my report (On Format) in the detail
section. My report hiccups with an Overflow error. I obviously didn't do
something else that is required. Can you help me further?
Thank you.
LCalaway
 
Hi Allen:

I have entered the following code in my report -- it doesn't work. There is
no other code behind the report. Any suggestions?

Option Compare Database
Option Explicit

Dim fBlankNext As Integer
Dim intLine As Integer

Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As
Integer)
intLine = 0
fBlankNext = False
End Sub


Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
If PrintCount = 1 Then intLine = intLine + 1
If fBlankNext Then
Me.PrintSection = False
Me.NextRecord = False
fBlankNext = False
Else
Me.PrintSection = True
Me.NextRecord = True
fBlankNext = (intLine Mod 5 = 0)
End If
End Sub

Thank you.
LCalaway
 
1. Open the report in design view.

2. Right-click the grey bar titled "Detail", and choose Properies.

3. Make sure the On Print property is set to:
[Event Procedure]

4. Do the same for the On Format property of the PageHeaderSection.

If that still doesn't work, press F9 on the first line of in sub (the
"IF..." line), and trace what's happening.
 
I discovered the problem -- the report was written so long ago that I forgot
that the Detail section is set to invisible. I applied the "Detail" section
code to the section that is actually set to print the "detail." The report
then adds the blank lines.

There is another problem with the report. I have a footer to number the
pages, indicating " x page of xx pages." The report is 148 pages long,
but the footer reads on the last page "Page 148 of 126 Pages." Is there a
cure for this type of a counting error? (The report is 126 pages long
without the blank lines added.)

Thank you.
LCalaway


Allen Browne said:
1. Open the report in design view.

2. Right-click the grey bar titled "Detail", and choose Properies.

3. Make sure the On Print property is set to:
[Event Procedure]

4. Do the same for the On Format property of the PageHeaderSection.

If that still doesn't work, press F9 on the first line of in sub (the
"IF..." line), and trace what's happening.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

LCalaway said:
Hi Allen:

I have entered the following code in my report -- it doesn't work. There
is
no other code behind the report. Any suggestions?

Option Compare Database
Option Explicit

Dim fBlankNext As Integer
Dim intLine As Integer

Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As
Integer)
intLine = 0
fBlankNext = False
End Sub


Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
If PrintCount = 1 Then intLine = intLine + 1
If fBlankNext Then
Me.PrintSection = False
Me.NextRecord = False
fBlankNext = False
Else
Me.PrintSection = True
Me.NextRecord = True
fBlankNext = (intLine Mod 5 = 0)
End If
End Sub

Thank you.
LCalaway
 
Good morning

Sorry, I posted only a partial answer. Yesteday was a long day.

This following bit of code needs to be inserted:

Private Sub Report_Open(Cancel As Integer)
cLines = 0
End Sub

Best regards

Maurice St-Cyr
 
Back
Top