How to show record number in MS Access report table?

I use MS Access to create small office software. When we insert a record, the record identifier does not always follow a sequence of natural numbers starting with 1. but in the first column I want a self-generated serial number (SN).

SN | Discription | ----+---------------+ 1 | Computer | 2 | Mobile | 

I want these SNs to always start with 1 and count all the records in the report table. Help Plsease.

0
source share
1 answer

I assume your table name is inventory:

 SELECT DCOUNT("[Description]","[inventory]","[Description]<='" & [Description] & "'") AS rank, inventory.* FROM inventory ORDER BY [Description] 

The DCOUNT function counts the number of rows that meet the specified criteria. In this case, we count the number of lines that are less than the current one. Everything will work if the column you are using has unique values.

+1
source

Source: https://habr.com/ru/post/1502807/


All Articles