473,324 Members | 2,193 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Adding row numbers in an Access report

7
I want to add a row number for each record in a report. I will have 10 records on each page and I want them to restart at every new page. So counting from 1 to 10 and then resetting for every new page
I have used a textbox with control source set to 1 and running sum, but the problem is to get it to reset on a new page
Mar 22 '19 #1

✓ answered by twinnyfo

Assuming your text box is named txtCount, remove the control source.

In the Report's VBA Module:
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As Integer)
  5.     Me.txtCount = 0
  6. End Sub
  7.  
  8. Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
  9.     Me.txtCount = Me.txtCount + 1
  10. End Sub
I have tested this and it should work.

12 2733
twinnyfo
3,653 Expert Mod 2GB
In the Report's Page Header On Format property, set the value of the text box to 1.
Mar 25 '19 #2
narvid
7
Hi,

Thank you for the answer, but I have the textbox in the "detail" section of the report to have a new row number for each record.

Page 1
1. Alan
2. Bob
3. Ceasar

Page 2
1. David
2. Eric
3. Fred

Can I use some variable that resets every page break?
Mar 27 '19 #3
twinnyfo
3,653 Expert Mod 2GB
Assuming your text box is named txtCount, remove the control source.

In the Report's VBA Module:
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As Integer)
  5.     Me.txtCount = 0
  6. End Sub
  7.  
  8. Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
  9.     Me.txtCount = Me.txtCount + 1
  10. End Sub
I have tested this and it should work.
Mar 27 '19 #4
narvid
7
Thank you

It looks logical but I can't get it to work.
I added the code exactly as above, removed the control source, renamed the text box to txtCount
but it doesn't show any row numbers in the report

I use Access 2013, could that be a problem?

Do I need to add something in the "expression builder" ?
Mar 28 '19 #5
twinnyfo
3,653 Expert Mod 2GB
Does your Report have a visible header? If not, it must have one, even if you set its height to 0.0104"
Mar 28 '19 #6
narvid
7
It has a header, was set to 0mm height.
I set it to 0.011mm, but it still won't show
Mar 28 '19 #7
twinnyfo
3,653 Expert Mod 2GB
Page or report header? Should be the Page header.
Mar 28 '19 #8
narvid
7
I also have a visible page header with some text (headings and title)

Instead of row numbers the text "#Name?" is shown at the beginning of each row/record
Mar 29 '19 #9
twinnyfo
3,653 Expert Mod 2GB
I have no clue what you are doing differently.


Attached Images
File Type: jpg Narvid1.jpg (29.9 KB, 1031 views)
File Type: jpg Narvid2.jpg (27.3 KB, 1035 views)
Attached Files
File Type: zip Narvid.zip (20.6 KB, 62 views)
Mar 29 '19 #10
narvid
7
Thank you for your patience and your great solution. It is exactly what I want my report to do. I can't see any differences, but I will try to build it up from the beginning, using your example, to get it to work.

Thanks a lot
Mar 29 '19 #11
narvid
7
When I rebuilded my report, I managed to get it to work. I still can't get it, why it didn't work with the original report, but anyway, now I got a working report. Thanks again Twinnyfo.
Apr 2 '19 #12
twinnyfo
3,653 Expert Mod 2GB
It probably didn't work with the original report because Access has a mind of its own. There might be a very perfectly logical reason for its not working. But I just chalk it up to malevolent intelligence.

Glad we could hepp! Let us know if you come across any other challenges.
Apr 2 '19 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Nicola | last post by:
Hi Everyone, I am new to programming and would like to know how to open an access Report from within vb 6. I am trying to write a program to organise cross stitch threads. I have found out how...
2
by: Tom Weddell | last post by:
Can I call an Access report from VB.Net? (I'm using access as the backend.) Thanks in advance.
1
by: jeffgeorge | last post by:
Hi all. What is very simple in Excel, may not exist in Access. Does anyone know how to denote -1 as (1) in an Access Report. The main choices when formatting doesn't seem to include the...
15
by: Mark C | last post by:
All, I have exhaustingly been looking through the newsgroups in search of a way to systemically output an Access 97 report to a pdf file using the full version of Adobe Acrobat. I want the user...
8
by: Mike MacSween | last post by:
tblCourses one to many to tblEvents. A course may have an intro workshop (a type of event), a mid course workshop, a final exam. Or any combination. Or something different in the future. At...
6
by: DeniseY | last post by:
I have an Access report that is created on the fly by the user selecting the fields to be included. The Access report comes out fine, but I want it to automatically output to an Excel spreadsheet....
6
by: ssq | last post by:
I have an access Report A generated by Query A, I copied Query A as Query B and replaced some columns by adding new columns. So when ever I run Report A now referred to Query B I am getting the pop...
1
by: sonicfun2006 | last post by:
I have SQL Server Database and MS Access 2003 is connected with ODBC. I have very large amount of records in various tables. The database is very dynamic as it changes every minute. I’m trying to...
0
by: Catherine Dooley | last post by:
I'm trying to get an Access report to print the number of pages of the group instead of the number of the whole report. The code I'm using is below. The Debug statement in the middle shows that the...
1
by: rizwanbaig | last post by:
I want to add alphabatec serial numbers ni ms access report like a. b. c. e.
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.