Print blank lines till end of page

  • Thread starter Thread starter Coretta
  • Start date Start date
C

Coretta

HI

I'm trying to print a phone book in a particular way,
using Access Reports.
what I have in a table is:
Name's arranged alphabetically
and
Phone numbers (of course!)

Printing this data alphabetically, with a page break for
each Letter of the alphabet, is no problem at all with
Access reports.

The problem is:
How do I print blank lines (for future use) till
the end of the page- that is, till all records for -
say 'A' - are printed?
A line is being printed after each detail record.
This line is in the detail section of the report.

Thank you in anticipation.

Coretta
 
Coretta said:
I'm trying to print a phone book in a particular way,
using Access Reports.
what I have in a table is:
Name's arranged alphabetically
and
Phone numbers (of course!)

Printing this data alphabetically, with a page break for
each Letter of the alphabet, is no problem at all with
Access reports.

The problem is:
How do I print blank lines (for future use) till
the end of the page- that is, till all records for -
say 'A' - are printed?
A line is being printed after each detail record.
This line is in the detail section of the report.


To do this you need to know how many detail records are in
each group and which one is currently being processed.
Place a hidden text box named txtGroupCnt in the group
header section with the expression =Count(*). Then add a
hidden(?) text box named txtDetailNum to the detail section
with the expression =1 and RunningSum set to Over Group.

Now you can add code to the detail section's Format event to
reprint the section after the last detail in the group.
Here's some air code to give you the general idea.

Sub Detail_Format( . . .
Dim bolShow As Boolean

If txtDetailNum = txtGroupCnt Then
If Me.Top < lngBottom - Me.Section(0).Height Then
 
Coretta said:
I'm trying to print a phone book in a particular way,
using Access Reports.
what I have in a table is:
Name's arranged alphabetically
and
Phone numbers (of course!)

Printing this data alphabetically, with a page break for
each Letter of the alphabet, is no problem at all with
Access reports.

The problem is:
How do I print blank lines (for future use) till
the end of the page- that is, till all records for -
say 'A' - are printed?
A line is being printed after each detail record.
This line is in the detail section of the report.

Sorry about that. Hit the wrong button.

To do this you need to know how many detail records are in
each group and which one is currently being processed.
Place a hidden text box named txtGroupCnt in the group
header section with the expression =Count(*). Then add a
hidden(?) text box named txtDetailNum to the detail section
with the expression =1 and RunningSum set to Over Group.

Now you can add code to the detail section's Format event to
reprint the section after the last detail in the group.
Here's some code to give you the general idea.


' Page height less page footer height (in twips)
Const clngBottom As Integer = 6 * 1440

Private Sub Detail_Format(Cancel As Integer, _
FormatCount As Integer)
Static bolExtra As Boolean

'Check for first detail in group
If Me.txtDetailNum = 1 Then
Me.somecontrol.Visible = True
Me.anothercontrol.Visible = True
' . . .
bolExtra = False
End If

'Check for last detail in group or extra lines
If Me.txtDetailNum = Me.txtGroupCnt Then
If Not bolExtra Then
' Last detail
bolExtra = True
Me.NextRecord = False
Else 'Do extra lines
' Is there room for a blank line
If Me.Top < clngBottom _
- Me.Section(0).Height Then
Me.NextRecord = False
' Make data controls invisible
Me.somecontrol.Visible = False
Me.anothercontrol.Visible = False
' . . .
Else 'Page is full
Me.PrintSection = False
' Me.MoveLayout = False
End If
End If
End If
End Sub
 
Hi Marshall!

That was pretty cool stuff I learned from your
suggestions. Thanks for the same.

The blank lines get printed perfectly well till the end of
the page for the first group "A" but for the next group
onwards, the last (end) record of the group is printed
repeatedly till the end of the page.

Also, I changed the value of
' Make data controls invisible
Me.Line66.Visible = False
To
' Make data controls visible
Me.Line66.Visible = True

That is, (the complete code):
==========================================================
Private Sub Detail_Format(Cancel As Integer, FormatCount
As Integer)
Static bolExtra As Boolean
'Check for first detail in group
If Me.txtDetailNum = 1 Then
Me.Line66.Visible = True
'Me.anothercontrol.Visible = True
' . . .
bolExtra = False
End If

If Me.txtDetailNum = Me.txtGroupCnt Then
If Not bolExtra Then
' Last detail
bolExtra = True
Me.NextRecord = False
Else 'Do extra lines
' Is there room for a blank line
If Me.Top < 13921 Then ' clngBottom -
Me.Section(0).Height Then
Me.NextRecord = False
' Make data controls invisible
Me.Line66.Visible = True
'Me.anothercontrol.Visible = False
' . . .
Else 'Page is full
Me.PrintSection = False
' Me.MoveLayout = False
End If
End If
End If

End Sub
=======================================================
I cannot figure out why this last record of the group is
repeated till the end of page.
Any ideas?

Thank you, in anticipation.

Coretta
 
Coretta said:
That was pretty cool stuff I learned from your
suggestions. Thanks for the same.

The blank lines get printed perfectly well till the end of
the page for the first group "A" but for the next group
onwards, the last (end) record of the group is printed
repeatedly till the end of the page.

Also, I changed the value of
' Make data controls invisible
Me.Line66.Visible = False
To
' Make data controls visible
Me.Line66.Visible = True

That is, (the complete code):
==========================================================
Private Sub Detail_Format(Cancel As Integer, FormatCount
As Integer)
Static bolExtra As Boolean
'Check for first detail in group
If Me.txtDetailNum = 1 Then
Me.Line66.Visible = True
'Me.anothercontrol.Visible = True
' . . .
bolExtra = False
End If

If Me.txtDetailNum = Me.txtGroupCnt Then
If Not bolExtra Then
' Last detail
bolExtra = True
Me.NextRecord = False
Else 'Do extra lines
' Is there room for a blank line
If Me.Top < 13921 Then ' clngBottom -
Me.Section(0).Height Then
Me.NextRecord = False
' Make data controls invisible
Me.Line66.Visible = True
'Me.anothercontrol.Visible = False
' . . .
Else 'Page is full
Me.PrintSection = False
' Me.MoveLayout = False
End If
End If
End If

End Sub
=======================================================
I cannot figure out why this last record of the group is
repeated till the end of page.


First, let's clear up the typo in my code, remove the ' at
the start of the Me.MoveLayout = False.

The reason the last record is repeated is because you didn't
make those controls invisible when printing the extra lines.

I'm not sure how it worked for the first group, but you need
to set the visiblility of all the controls in the detail
section. For each control in the detail, add a line to the
top part to make them visible and the Line invisible:

If Me.txtDetailNum = 1 Then
Me.Line66.Visible = False 'Don't show line
' Show all other controls
Me.allothercontrols.Visible = True
' . . .
bolExtra = False
End If

Similarly, add line for each control to the lower section to
reverse the control's vidibility:

If Me.Top < 13921 Then
Me.NextRecord = False
Me.Line66.Visible = True 'Show line
' Hide all other controls
Me.allothercontrols.Visible = False
' . . .
--
Marsh
MVP [MS Access]


 
Hi Marshall!

Removing that typo removes a whole lot of queries
regarding printing Access reports. But there still is one
question re. your code: What if the group has only one
record? I have only one record for Q and one for Z.

There seens to be an infinite loop in these cases (Q and
Z). Tried fixing this but I either get the lines till the
end of the page and no detail record printed for Q and Z
respectively, or the detail record is printed but no lines
till the EOP.

Thank you in anticipation.

Coretta
 
Coretta said:
Removing that typo removes a whole lot of queries
regarding printing Access reports. But there still is one
question re. your code: What if the group has only one
record? I have only one record for Q and one for Z.

There seens to be an infinite loop in these cases (Q and
Z).


Complete brain fault on my part, Coretta. No excuse for
this, but you have my apologies for all the confusion.

The top part of that procedure needs to be in the group
header's Format event (create an invisible group header if
you don't have one already). Then the code would be:
--------------------------------------------------
Dim bolExtra As Boolean

Private Sub GroupHeader0_Format(Cancel As Integer, _
FormatCount As Integer)
'Setup for first detail in group
Me.somecontrol.Visible = True
Me.anothercontrol.Visible = True
' . . .
bolExtra = False
End Sub

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

'Check for last detail in group or extra lines
If Me.txtDetailNum = Me.txtGroupCnt Then
If Not bolExtra Then
' Last detail
bolExtra = True
Me.NextRecord = False
Else 'Do extra lines
' Is there room for a blank line
If Me.Top < 13921 Then
Me.NextRecord = False
' Make data controls invisible
Me.somecontrol.Visible = False
Me.anothercontrol.Visible = False
' . . .
Else 'Page is full
Me.PrintSection = False
Me.MoveLayout = False
End If
End If
End If
End Sub
 
I'm jumping in without knowing the whole story so cough politely and ignore
this if it doesn't apply.

Could you make the details section into a subreport?

Your main report would be based on a table called TblAlphabet with guess
what in its one field (called Init) and 26 records.

The subreport's query has one field called
Init:Left$([YourNameField],1)

This field in the Data tab of the report's properties is linked with the
Init field in the main report.



Put a box into the main report's details section to act as a frame and draw
lines across it. Make it tall enough so that it just fills your page. Don't
have any lines or anything except records in the subreport. (Heading labels
are probably best in the Main report). Set the Main Report's details section
to Can't Grow or Shrink.
It will take some twiddling to get the lines in the right place but it can
be done.

Evi
 
Back
Top