Inserting serial numbers from 1 to 20 in each page of a report in access

Joined
Mar 22, 2016
Messages
14
Sir, i have 324 records to display as output . each page in my report shoud contain 20 records with serial numbers from 1 to 20 pls help to do this. For eg. each page should show serial numbers from 1 to 20
 
Last edited:

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
What you can try:
- create a group if there is a relationship between the 20 records such that the next 20 belong to some other sort of group, and the next 20 to some other group, etc.
- if you cannot group, size and/or space the row(s) of controls in the detail section so that only 20 rows will fit
- size the page footer so that only 20 records will fit. This will create extra space at the bottom. If you have page counter or date showing in the page footer, you would have to move that to the bottom so that there's not a whole lot of space after it.
- using vba code in the report Format event to start a new page after 20 records. This is more complicated and may only work for the print preview and not the report view. You would also need a textbox (can be hidden) say, txtRowCount; whose control source is set to =1 and set it to Running Sum - over group. A code example for this:
Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If txtRowCount Mod 20 = 0 Then
   Detail.ForceNewPage = 2   'create new page
Else
   Detail.ForceNewPage = 0   'not 20 records yet; don't create new page
End If
End Sub
Not sure how you'd show the row number if you need it.
 
Last edited:
Upvote 0
Cross-posted: Inserting serial numbers form 1 to 20 in each report page

While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule #13 here along with the explanation: Forum Rules). This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 
Upvote 0
What you can try:
- create a group if there is a relationship between the 20 records such that the next 20 belong to some other sort of group, and the next 20 to some other group, etc.
- if you cannot group, size and/or space the row(s) of controls in the detail section so that only 20 rows will fit
- size the page footer so that only 20 records will fit. This will create extra space at the bottom. If you have page counter or date showing in the page footer, you would have to move that to the bottom so that there's not a whole lot of space after it.
- using vba code in the report Format event to start a new page after 20 records. This is more complicated and may only work for the print preview and not the report view. You would also need a textbox (can be hidden) say, txtRowCount; whose control source is set to =1 and set it to Running Sum - over group. A code example for this:
Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If txtRowCount Mod 20 = 0 Then
   Detail.ForceNewPage = 2   'create new page
Else
   Detail.ForceNewPage = 0   'not 20 records yet; don't create new page
End If
End Sub
Not sure how you'd show the row number if you need it.


sorry Sir, the code doesn't work
 
Last edited:
Upvote 0
Not only do you cross post without regard but you don't concern yourself with guidelines given for posting. See my #1 tip in my signature. The first we can attribute to not knowing any better. The other is just inattention. Sorry, I can't help further.
 
Last edited:
Upvote 0
Make the field shown in the above post: called ForNum, with Control Source set to =1, and to Running Sum: Over Group. This can be hidden.

Another field: Called TestN with this as the Control Source: =[ForNum] Mod 20. Hidden also.

Then another field with this as the Control Source: =IIf([ForNum] Mod 20=0,20,[ForNum] Mod 20). This field will give you the numbers 1 to 20 repeated over and over.

Next in the On Format part of the Event part of the Detail Section:
Code:
 Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)


    If [TestN] = 0 Then
       Me.Detail.ForceNewPage = 19
 Else
     Me.Detail.ForceNewPage = 0
 End If
    
End Sub

Seems to work on a sample I've tried.
 
Upvote 0

Forum statistics

Threads
1,216,126
Messages
6,129,021
Members
449,480
Latest member
yesitisasport

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top