PC Review


Reply
Thread Tools Rate Thread

Auto Increment from a one number table

 
 
fiaola
Guest
Posts: n/a
 
      7th Jan 2008
Hi All,

I want to be able to auto increment a number, but I don't wan to use the
AutoInc feature of Access due to problems that i forsee when i have to reset
the number in the future.

What is the best way to do this? Can you post some example? or website that
may have this information?

Thanks for answering.


 
Reply With Quote
 
 
 
 
Beetle
Guest
Posts: n/a
 
      7th Jan 2008
You can use the DMax function (you'll find info on it in your Access help
file) to return the maximum existing number, and then add one to it.

However, it depends on what you mean by *reset the number*. If you plan on
deleting all the existing records and starting over from 1 (or whatever),
then Dmax should work. On the other hand, if you plan on keeping the existing
records and just *resetting* your numeric field, then you will need some
other field to keep track of which record is the most recent. You may still
be able to use DMax, but you'll have to retrieve the max value from the other
field

--
_________

Sean Bailey


"fiaola" wrote:

> Hi All,
>
> I want to be able to auto increment a number, but I don't wan to use the
> AutoInc feature of Access due to problems that i forsee when i have to reset
> the number in the future.
>
> What is the best way to do this? Can you post some example? or website that
> may have this information?
>
> Thanks for answering.
>
>
>

 
Reply With Quote
 
John W. Vinson
Guest
Posts: n/a
 
      8th Jan 2008
On Mon, 7 Jan 2008 09:35:16 -1100, "fiaola" <(E-Mail Removed)> wrote:

>Hi All,
>
>I want to be able to auto increment a number, but I don't wan to use the
>AutoInc feature of Access due to problems that i forsee when i have to reset
>the number in the future.
>
>What is the best way to do this? Can you post some example? or website that
>may have this information?
>
>Thanks for answering.
>


What do you mean by a "one number table"? What are you going to actually do
with this number, and where will it be stored?

John W. Vinson [MVP]
 
Reply With Quote
 
fiaola
Guest
Posts: n/a
 
      8th Jan 2008
The problem with AutoInc is because the value becomes a PK and If my company
wants to change the number from 100 to 1000, we can't just do it without
compacting and deleting all data.

I want to be able to create a table such as NEXTNUMBER, with only one field
called NextValue. I should be able to READ the current value and add 1 and
do it in an INSERT or NEWRecord event. After that, then i need to update
the NextNumber table.

"John W. Vinson" <jvinson@STOP_SPAM.WysardOfInfo.com> wrote in message
news(E-Mail Removed)...
> On Mon, 7 Jan 2008 09:35:16 -1100, "fiaola" <(E-Mail Removed)> wrote:
>
>>Hi All,
>>
>>I want to be able to auto increment a number, but I don't wan to use the
>>AutoInc feature of Access due to problems that i forsee when i have to
>>reset
>>the number in the future.
>>
>>What is the best way to do this? Can you post some example? or website
>>that
>>may have this information?
>>
>>Thanks for answering.
>>

>
> What do you mean by a "one number table"? What are you going to actually
> do
> with this number, and where will it be stored?
>
> John W. Vinson [MVP]



 
Reply With Quote
 
John W. Vinson
Guest
Posts: n/a
 
      8th Jan 2008
On Mon, 7 Jan 2008 14:27:29 -1100, "fiaola" <(E-Mail Removed)> wrote:

>I want to be able to create a table such as NEXTNUMBER, with only one field
>called NextValue. I should be able to READ the current value and add 1 and
>do it in an INSERT or NEWRecord event. After that, then i need to update
>the NextNumber table.


The code I use was published in Getz, Litwin & Gilbert's supurb _Access 97
Developer's Handbook_. It's been republished in later editions. It's
copyrighted so I won't post the code; but a variant of it has been published
in a Knowledge Base article:

http://support.microsoft.com/kb/210194

John W. Vinson [MVP]
 
Reply With Quote
 
fiaola
Guest
Posts: n/a
 
      8th Jan 2008
Thanks. That's exactly what i'm looking for.

"John W. Vinson" <jvinson@STOP_SPAM.WysardOfInfo.com> wrote in message
news:(E-Mail Removed)...
> On Mon, 7 Jan 2008 14:27:29 -1100, "fiaola" <(E-Mail Removed)> wrote:
>
>>I want to be able to create a table such as NEXTNUMBER, with only one
>>field
>>called NextValue. I should be able to READ the current value and add 1
>>and
>>do it in an INSERT or NEWRecord event. After that, then i need to update
>>the NextNumber table.

>
> The code I use was published in Getz, Litwin & Gilbert's supurb _Access 97
> Developer's Handbook_. It's been republished in later editions. It's
> copyrighted so I won't post the code; but a variant of it has been
> published
> in a Knowledge Base article:
>
> http://support.microsoft.com/kb/210194
>
> John W. Vinson [MVP]



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto Increment Number ChoonBoy Microsoft Access Form Coding 6 10th Jul 2009 12:15 PM
Auto Increment Number E_Dirksen Microsoft Excel Misc 1 24th Jun 2008 10:01 PM
Re: How to generate a auto number or increment number strive4peace Microsoft Access Queries 1 19th Apr 2008 10:20 PM
Auto Increment Number =?Utf-8?B?UnVzdHk=?= Microsoft Access 4 10th Jul 2006 12:13 PM
Auto Number increment by 2 Tracey Microsoft Access Database Table Design 0 9th Sep 2003 09:56 AM


Features
 

Advertising
 

Newsgroups
 


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