Auto number delete

ahmedismailfourtex

Board Regular
Joined
Apr 28, 2015
Messages
124
Hello,
I'm using the auto number to generate the invoice number
When I delete or undo one the new one didn't take the deleted number it's make problem in our calculations any way to solve this? ??
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Please provide an example of what you have, what you are doing, and what you expect.
 
Upvote 0
any way to solve this?
Yeah, give up on the idea. Autonumbers should not be used for this purpose - there is just too much that can go wrong, aside from not always being sequential, which is what I think you are saying. You cannot delete a record and expect Access to reuse the autonumber you deleted in order to keep the sequence going. There are better ways.

One would be to find the last saved value in an indexed (no dupes) field and increment by whatever you want and use that. In a multiuser db, that can cause write conflicts when two people are in create mode and one has not saved the record they're working on IF you try to start the record creation with that number. Create the number when the record is completed and saved, otherwise, they are each starting a record with the same ID.

Another way would be to store the NextInvNum in a table. This value could be updated when a record is started or saved. On start, a concurrent user updates this value thus starts with a different ID.

In either case, committing the ID at the start means the potential drawback is that if one user cancels the record, the ID is not sequential. If that is really that important, the record could exist but the ID could be statused as Cancel. Even paper based systems did not enforce sequential ID's. It's impossible to guarantee that a numbered paper document would not get totally screwed up and end in the waste basket, so why try enforce sequental IDs? The only way I know of that you can 99.9% ensure sequential IDs is to assign someone the task of meteing them out one by one, only when the record is ready to be committed as complete. Otherwise, the second method should work IF the record ID is created when the record is finished and will NOT ever need to be deleted.
 
Last edited:
Upvote 0
As a general rule, don't delete things. Use a field such as IsCancelled or Void. Then you have an audit trail. Also change the way you do your calculations. They shouldn't rely on something that can be deleted ;)
 
Upvote 0
Hello,
I'm using the auto number to generate the invoice number
When I delete or undo one the new one didn't take the deleted number it's make problem in our calculations any way to solve this? 

The autonumber is working correctly. I would solve this by fixing your calculation.
 
Upvote 0

Unfortunately I can't help much since I have not seen the calculation.

My guess would be that you are trying to get a count of records by by using the autonumber in some way.. If yes, it is best to use a query to elect the desired records and get a record count. A Totaling Query can easily get a Count. .
 
Upvote 0

Forum statistics

Threads
1,221,834
Messages
6,162,268
Members
451,758
Latest member
lmcquade91

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top