Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

For the picture http://i.stack.imgur.com/Bn4n5.png

Current record number

share|improve this question

migrated from stackoverflow.com Oct 3 '12 at 12:02

This question came from our site for professional and enthusiast programmers.

1 Answer 1

up vote 2 down vote accepted

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

share|improve this answer
    
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 Oct 3 '12 at 10:02
    
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 Oct 3 '12 at 10:11
    
Some code for sequential numbers: stackoverflow.com/questions/11949603/… –  Remou Oct 3 '12 at 10:14
    
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 Oct 3 '12 at 10:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.