If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Autoincrement
How do I create my autoincrement number?
My Table main_index (AutoNumber), payee_id (Number), main_amount (Currency), main_receipt (Number) if my Last Receipt Number was 500, I would like to update my main_receipt with the next number 501, 502, 503, etc, etc, according th main_idex field. Thank you all, Bre-x |
#2
|
|||
|
|||
Autoincrement
If you are using Access' Autonumber data type, be aware that it is ONLY
designed to provide a unique identifier. It is not guaranteed to be sequential, and is generally unfit for human consumption. If you MUST have a sequential number (i.e., a "sequence number"), you'll need to 'roll your own' code to generate it. Check online for "custom autonumber" for variations on how to do this. Note, you can keep your Autonumber primary key, but you'll need to add a numeric-type field to hold your (new) sequence number. Regards Jeff Boyce Microsoft Access MVP -- Disclaimer: This author may have received products and services mentioned in this post. Mention and/or description of a product or service herein does not constitute endorsement thereof. Any code or pseudocode included in this post is offered "as is", with no guarantee as to suitability. You can thank the FTC of the USA for making this disclaimer possible/necessary. "Bre-x" wrote in message ... How do I create my autoincrement number? My Table main_index (AutoNumber), payee_id (Number), main_amount (Currency), main_receipt (Number) if my Last Receipt Number was 500, I would like to update my main_receipt with the next number 501, 502, 503, etc, etc, according th main_idex field. Thank you all, Bre-x |
#3
|
|||
|
|||
Autoincrement
I coundn't find what I am looking for, most of the instructions are to reset
the autonumber. I am looking for a way to auto increment a field. After a few hundred records have been inserted I need to find a way to auto increase the main_receipt starting from a number in another table. Help!!!!!! Bre-x "Jeff Boyce" wrote in message ... If you are using Access' Autonumber data type, be aware that it is ONLY designed to provide a unique identifier. It is not guaranteed to be sequential, and is generally unfit for human consumption. If you MUST have a sequential number (i.e., a "sequence number"), you'll need to 'roll your own' code to generate it. Check online for "custom autonumber" for variations on how to do this. Note, you can keep your Autonumber primary key, but you'll need to add a numeric-type field to hold your (new) sequence number. Regards Jeff Boyce Microsoft Access MVP -- Disclaimer: This author may have received products and services mentioned in this post. Mention and/or description of a product or service herein does not constitute endorsement thereof. Any code or pseudocode included in this post is offered "as is", with no guarantee as to suitability. You can thank the FTC of the USA for making this disclaimer possible/necessary. "Bre-x" wrote in message ... How do I create my autoincrement number? My Table main_index (AutoNumber), payee_id (Number), main_amount (Currency), main_receipt (Number) if my Last Receipt Number was 500, I would like to update my main_receipt with the next number 501, 502, 503, etc, etc, according th main_idex field. Thank you all, Bre-x |
#4
|
|||
|
|||
Autoincrement
On Wed, 5 May 2010 10:39:00 -0600, "Bre-x" wrote:
How do I create my autoincrement number? My Table main_index (AutoNumber), payee_id (Number), main_amount (Currency), main_receipt (Number) if my Last Receipt Number was 500, I would like to update my main_receipt with the next number 501, 502, 503, etc, etc, according th main_idex field. If (as you should!) you are doing your data entry through a Form, you can put code in the form's BeforeInsert event: Private Sub Form_BeforeInsert(Cancel as Integer) Me!main_receipt = NZ(DMax("[main_receipt]", "[yourtablename]")) + 1 End Sub You may want to consider that main_index and main_receipt are now functionally equivalent (both are Long Integer unique identifiers for the record); you could consider making main_receipt the Primary Key and removing the autonumber field altogether. This will require some snarky update queries if you have related tables, however. -- John W. Vinson [MVP] |
#5
|
|||
|
|||
Autoincrement
Roger Carlson has simple solutions for both single and multi-user
environments at: http://www.rogersaccesslibrary.com/forum/topic395.html while my slightly more complex solution at: http://community.netscape.com/n/pfx/...g=ws-msdevapps also allows the number to be 're-seeded' with a number at which the sequence will re-start when the next record is added. This could be adapted to re- start the sequence with your number from another table. Ken Sheridan Stafford, England Bre-x wrote: I coundn't find what I am looking for, most of the instructions are to reset the autonumber. I am looking for a way to auto increment a field. After a few hundred records have been inserted I need to find a way to auto increase the main_receipt starting from a number in another table. Help!!!!!! Bre-x If you are using Access' Autonumber data type, be aware that it is ONLY designed to provide a unique identifier. It is not guaranteed to be [quoted text clipped - 28 lines] Bre-x -- Message posted via http://www.accessmonster.com |
#6
|
|||
|
|||
Autoincrement
Thank you very much.
"KenSheridan via AccessMonster.com" u51882@uwe wrote in message news:a79d8fd9ee7c7@uwe... Roger Carlson has simple solutions for both single and multi-user environments at: http://www.rogersaccesslibrary.com/forum/topic395.html while my slightly more complex solution at: http://community.netscape.com/n/pfx/...g=ws-msdevapps also allows the number to be 're-seeded' with a number at which the sequence will re-start when the next record is added. This could be adapted to re- start the sequence with your number from another table. Ken Sheridan Stafford, England Bre-x wrote: I coundn't find what I am looking for, most of the instructions are to reset the autonumber. I am looking for a way to auto increment a field. After a few hundred records have been inserted I need to find a way to auto increase the main_receipt starting from a number in another table. Help!!!!!! Bre-x If you are using Access' Autonumber data type, be aware that it is ONLY designed to provide a unique identifier. It is not guaranteed to be [quoted text clipped - 28 lines] Bre-x -- Message posted via http://www.accessmonster.com |
Thread Tools | |
Display Modes | |
|
|