Home > database >  How to implement the access built-in automatic number starting from 1 to number
How to implement the access built-in automatic number starting from 1 to number

Time:10-17

See below, figure 1


Deleted after a few lines, the following figure, figure 2


Automatic number becomes discontinuous, seek expert advice on how to set up a form of automatic numbering can delete the content can automatically update to arrange the serial number of consecutive


CodePudding user response:

Can consider to delete the increase automatic field, and to add (this process can be implemented with the mouse operation can also use the code), so will reorder,

CodePudding user response:

As a first step, get rid of a relational table
The second step, into the diagrams of the table design, delete the automatic numbering, and recreate and renamed
Step 3 save, into into this form will be reordered

CodePudding user response:

In design view change the number of this field data type to "automatic" no. ""

CodePudding user response:

Try the following ideas:
In the program, to delete records this action design into several steps:
1, first remove the specified records (such as: delete from table where id=vid)
2, read all the table data to array
3, delete all the data table (delete from table)
4, compression, and restore the table (for example, using vb CompactDatabase)
5, moved back to the data from the array

So every time to delete records operation, can keep the continuity of automatic number field,
Specific code to write their own design, do not know you specific use what language programming,

Disadvantages: for a large quantity of data table, may be slower, efficiency is not high,

If it is directly by hand in the access to delete table, that's no way to automatically number field to adjust its continuity,

Actually don't need to care about the continuity of the automatic number field, most of the time, can use other ways to achieve continuous display of the serial number,

For reference only,

CodePudding user response:

More stupid way is every time a compression and repair the database...

CodePudding user response:

When the input data in the table directly, every delete, manual compression and repair the database once,

You can also take number column is set to "digital", no "automatic numbering", so that you can easily import, however, automatic growth, repetitive control requires more complex methods, such as

VBA in the new ACCESS, seems to have not automatic compression and repair the database "",
  • Related