Access is a relational database thingy. Autonumbers used for primary keys can act as foreign keys in other tables. If you delete a record with an autonumber and that key is foreign in another table (you may not have Cascade Delete selected) then the records in the other table could connect (wrongly!) with the new autonumber if, as you suggest, it was to replace a missing number.
The autonumber is used although it's value shouldn't matter to you. It's can be used for realting fields in different tables. I hope you are not using the autonumber as a visible ID within your database.
It's just an incrementer of records; not a counter of recods.
Ok, I understan that we should not use the autonumber as a PRIMARY KEY ON THE TABLE... I created a table that has a LeaseId and its the primary key on it.
Now this number should only increment when you create a record right? Well this is happening to me, I open the Lease Form, the Lease Number is the LeaseID. When I start a record and decide not to create it I just close the form.
I then goto the table and I can see that there is no record created but if I go back to the form the LeaseId does increment to the next number...
Why is this happening if there is no record created?
An autonumber is assigned as soon as you start to create a new record, whether or not the new record is saved or not is irrelevant. The number has been assigned and therefore can not be used again.
Also it is perfectly alright to use an autonumber as a primary key, an autonumber should not however be used for any other purpose.
Ok, I understan that we should not use the autonumber as a PRIMARY KEY ON THE TABLE... I created a table that has a LeaseId and its the primary key on it.
this isnt correct - of course you have an autonumber as a PK
the point is that in general an autonumber should not be used as a reference number etc etc in your system. many developers hide autonumbers, so users dont even know they are there. the ONLY purpose for an autonumber is to generate a unique (primary) key, that can be used to relate items in different tables
if you need a sequential reference then you need a different technique to generate the reference - in which case its a matter of taste whether you still have the autonumber, or instead use the manual sequential reference as your primary key - although note that it is beeter to use numbers as keys, rather than text strings
note that there is always an issue with maintaining sequences
even if you have manual control, and you have keys
17
18
19
20
21
etc, and delete row 19 from the table, you now have no row 19. But you have a real practical problem if you try to fill the gaps. thats why its better to flag unwanted rows as "dead", rather than delete them.
Thanks I knwo understand. Now I have another issue, I have created the main form and subform for the Leases, this is the setup or better yet I will upload the DB. Ok when I create a Lease I first fill out the Main Form, now it should not let me save anything on the main form if there is no record on the subform right? Well its doing this. I have created other databases before in Access2003 and dont remember this happening. Example I created a database for a little store I had in Nicaragua, I remember that I needed to have a product on the invoice for the form to close otherwise it would show a msg thet the primary key was null.. I also have lots of other questiosn on this DB that I am creating, if you love access and would like to help me one on one it would be great. We either do it here or here is my Aim=daniboy1969 and MSN=jdcallejas@hotmail.com
Where'd you get THAT idea?? You are reversed you SHOULD use an Autonumber as a PRIMARY KEY but for NOTHING ELSE, unless you can live with gaps or negative numbers or jumps by the hundreds or thousands.
Why is this happening if there is no record created?
Access will assign an autonumber when you start to create a record and if the record is abandoned so is the autonumber, so it starts with the next one when creating the next record. It doesn't matter at all if you set things up right because your users will NEVER SEE the primary key autonumber. You can display other things for them but an autonumber should be considered a SYSTEM thing and the SYSTEM should manage them and use them but they are not meant "for human consumption."