How to return current record number in Access?

2

I want to have my table to automatically returns current record number.

What functions should I input in default value of this field (indicated in blue arrow) in order to automatically generates number based on their current record?

For example, in this table, it should be filled with number "1". If I create a new record, then it also automatically filled with number "2" respectively.

Current record number:

enter image description here

imsus

Posted 2012-10-03T08:49:09.543

Reputation: 35

Answers

2

You should set up most of your tables so that they use autonumbers and then the field will be completed for you.

autonumber design view

Remou

Posted 2012-10-03T08:49:09.543

Reputation: 298

OK, but what I want is I'm going to use the number from "No" field in order to create "ID" which will be based on calculation between "No" field and "Tanggal" field. So the ID will be unique. But what I want is the "No" field value is based on current record number. – imsus – 2012-10-03T10:02:39.693

There is no such thing as a fixed current record number in a relational database. The current record number, such that there is one, depends on the sort order of the table. If you wish to assign a sequential number to records, you will need VBA, or just take the easy way and use an autonumber. – Remou – 2012-10-03T10:11:42.447

Some code for sequential numbers: http://stackoverflow.com/questions/11949603/access-vba-find-max-number-in-column-and-add-1/11950647#11950647

– Remou – 2012-10-03T10:14:43.717

Oh, my bad. I forgot the algorithm won't work when sort and filter is being applied. I guess I will use Autonumber instead. Thanks – imsus – 2012-10-03T10:23:27.307