I want to start numbering my records at a certain number

C

Carla

I have created a new database but I want to continue the numbering from the
previous one AND I want the database to automatically fill in the next number
on the data entry form. How do I do this?
 
B

Brian

You could use AutoNumber, append in enough dummy records to get up to one
less than the number where you want it to start, then delete the dummy
records. Just don't do a compact/repair until after a valid new record is
entered. The AutoNumber does not get reset back to zero unless a
compact/repair is done whil the table is empty.

Alternatively:

Instead of using AutoNumber in the table, set the data type as Long Integer
and do something like this on your form:

Set the default value of that field (let's call it CustomerID, from the
Customers table) to:

=IIf (DCount ("[CustomerID]","[Customers]")=0, <Enter your starting number
here>,DMax("[CustomerID]","[Customers]")+1)

This will assign the starting number to the first customer entered and
increment from there onward. This is not quite like AutoNumber in that if one
user opens the form while another user has an unsaved record open on the
form, they will both get the same number - a perennial database problem. You
can alleviate this by checking to see if the number already exists right
before you save the record (Form_BeforeUpdate) and incrementing it again
until it comes up with an unused number. This will be a moot point if this is
a single-user application.
 
P

peregenem

You could use AutoNumber, append in enough dummy records <snips>

Alternatively:

Instead of using AutoNumber in the table <snips>
From the help file, glossary:

http://office.microsoft.com/en-us/assistance/HP010441931033.aspx#S

seed
Optional parameter used with the Counter or Indentity data types.
Available in SQL DDL only when utilizing the Microsoft OLE DB Provider
for Jet. Can also be referred to as the starting value. The seed is the
first of the two optional parameters to the Counter or Identity data
types. The following SQL statement is an example with the
parameters:CREATE TABLE Customers (CustId IDENTITY (100, 10) CONSTRAINT
pkCustomers PRIMARY KEY, CFrstNm VARCHAR(10), CLstNm VARCHAR(15));The
column CustId in the first row will have a value of 100. The second row
will have a value of 110.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top