A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Autoincrement



 
 
Thread Tools Display Modes
  #1  
Old May 5th, 2010, 05:39 PM posted to microsoft.public.access.gettingstarted
Bre-x
external usenet poster
 
Posts: 103
Default 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  
Old May 5th, 2010, 05:47 PM posted to microsoft.public.access.gettingstarted
Jeff Boyce
external usenet poster
 
Posts: 8,621
Default 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  
Old May 5th, 2010, 08:02 PM posted to microsoft.public.access.gettingstarted
Bre-x
external usenet poster
 
Posts: 103
Default 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  
Old May 5th, 2010, 09:21 PM posted to microsoft.public.access.gettingstarted
John W. Vinson
external usenet poster
 
Posts: 18,261
Default 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  
Old May 6th, 2010, 09:57 PM posted to microsoft.public.access.gettingstarted
KenSheridan via AccessMonster.com
external usenet poster
 
Posts: 1,610
Default 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  
Old May 10th, 2010, 03:14 PM posted to microsoft.public.access.gettingstarted
Bre-x
external usenet poster
 
Posts: 103
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:56 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.