View Single Post
  #2  
Old February 11th, 2010, 08:45 PM posted to microsoft.public.access.tablesdbdesign
Stefan Hoffmann
external usenet poster
 
Posts: 991
Default Filling in voids in the id number

hi Tes,

On 11.02.2010 21:33, TES wrote:
My first column is the key and ID number for each record. One of my users
(before I locked the table) voided several of the records, and now the record
number and Id number no longer match. Is there a way to back fill the key-id
number with dummy records so the rows line up.

If you need a continuous number without gaps, then you must calculated
it before storing the records. You cannot use an auto number for that
purpose.

Use

Nz(DMax("number", "tableName"), 0) + 1

to calculate it. E.g. in the before insert event of a form:

Private Sub Form_BeforeInsert(Cancel As Integer)

Me![number] = Nz(DMax("number", "tableName"), 0) + 1

End Sub



mfG
-- stefan --