Solved PK numbers missing

leave it as is, it will not create new number, yet.
the recordset is just positioned to the "New" record.
once you start typing something on this New record, then
it will use the Next autonumber.
if I leave this line than form has stay correct data page. Because recordSET code so, how I put new data or new record.
by the ways, can you give me a idea that never gap any numbers when I passed save button.
Thank you.
 
then don't use Autonumber field.
create a function that will build the "next" number for you.
 
then don't use Autonumber field.
create a function that will build the "next" number for you.
SIR, I use the function also DoCmd.GoToRecord , , acNext
but problem is when I close the form then previous record is missing. I means, when I click the next.... If I forget to write anything or forget to close the form then this numbers not back, coming new another numbers.

NOTE: My EmployeeID = Autonumber Yet., I can't change it. because so much table are linked with this ID.
 
It seems that we are not getting the point across, so let's try another question. WHY is it so important that you have contiguous numbering? If that is an employee ID and some employee dies, is fired, or quits, you will now have a gap in the active numbers. So what is the actual requirement that says you must have continuous numbering? If this is some kind of in-house auditor requirement, tell him to buzz off. All of the other possible methods that would give you continuous numbering require you to do a DCount or DMax aggregate function in the "BeforeUpdate" event AND require you to have error handling in place in case you had a "collision" with another person who also wanted to add an employee record.

I can't change it. because so much table are linked with this ID.

Which is exactly the point. If it is a PK, it is a number that you MUST not edit - because of relational integrity, whether you have that turned on or not. That is the most important aspect of prime keys. Constancy or immutability, however you wish to say that.

If I forget to write anything or forget to close the form then this numbers not back, coming new another numbers.

The behavior you just described is exactly the way autonumbers are supposed to work. The problem here is your expectation of an autonumber. It will NEVER give you absolutely contiguous numbers in a real-life situation.
 
but problem is when I close the form then previous record is missing.
This is not normal behavior. Can you post the database so we can reproduce the problem.
 
If I forget to write anything or forget to close the form then this numbers not back, coming new another numbers.
I'm not sure I'm following your explanations. If you start a new record and for any reason back out, undo etc, that autonumber will be gone and can not be reused.
Suggest you follow Pat's request and post a copy of the database, AND include instructions to follow the procedure you are using.
 

Users who are viewing this thread

Back
Top Bottom