Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Counting records before a Page Break

Status
Not open for further replies.

jmc014

Technical User
Nov 24, 2007
80
ES
Hi,

Is it possible to count the amount of records that are displayed on a report, let me explain. I'm using the following code that limits the amount of records shown on each report page:

Me.PgBrk.Visible = Me.TxtCount Mod 5 = 0

I'd like to know if it is possible to count the amount of records shoun in each detail.Can anyone point me in the right direction.

Thanks,
 
Is your objective to count records per page or set the maximum number of records on a page to 5?

If you want to insert a pagebreak after after 5th record, you can add a text box:
Name: txtCount
Control Source: =1
Running Sum: Over All
Visible: No
Then add code in the On Format event of the detail section:
Code:
   Me.PgBrk.Visible = Me.TxtCount Mod 5 = 0

Duane
Hook'D on Access
MS Access MVP
 
Hi there,

It is my objective to count records per page. If I have 8 records (shown in detail) the first page should show 5 and the second page should show 3.

I'm presently using the page break function exactly as you mention in your reply, sorry If my explanation was not clear enough.

Thanks,
 
No, I think your objective is to print no more than 5 records per page. Your solution suggests that in order to meet that objective, you need to have a method of counting records. The solution that I suggested provides a count of records.

Did the solution work or not? If not, what is happening? Are you using Access 2007? Are you viewing the print preview?

Duane
Hook'D on Access
MS Access MVP
 
Hello Duane,

When trying your solution, I get an error, saying "Method or data member not found" with the cursor highlighting me.txtCount. This is the code that I used for the detail section event in the report:
Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
   Me.PgBrk.Visible = Me.txtCount Mod 5 = 0
End Sub
- text box is named correctly
- Control is set to =1
- Running sum is set to "over all"
- Visible is: no

It looks right to me, but I can't put my finger behind this. This is puzzling me. Any advice?
 
Try add some parens
Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
   Me.PgBrk.Visible = (Me.txtCount Mod 5 = 0)
End Sub
This assumes the PgBrk and TxtCount are both in the detail section of the report.

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top