Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
Next number for an Autonumber field
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  8 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Lee Cartwright  
View profile  
 More options Sep 12 2000, 8:54 am
Newsgroups: microsoft.public.access.tablesdbdesign
From: "Lee Cartwright" <lee.cartwri...@bull.co.uk>
Date: Tue, 12 Sep 2000 13:46:09 +0100
Local: Tues, Sep 12 2000 8:46 am
Subject: Next number for an Autonumber field

Hi,

Is there anyway, within a query, to find out what the next number in an
incrementing Autonumber field will be?

Lee Cartwright


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John Spencer  
View profile  
 More options Sep 12 2000, 9:05 am
Newsgroups: microsoft.public.access.tablesdbdesign
From: John Spencer <spen...@chpdm.umbc.edu>
Date: Tue, 12 Sep 2000 09:08:19 -0400
Local: Tues, Sep 12 2000 9:08 am
Subject: Re: Next number for an Autonumber field
Not that I know of.  

You could get the maximum number used and still in the database.  That would
work as long as you never delete records or cancel a record before input.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeff Boyce  
View profile  
 More options Sep 12 2000, 2:02 pm
Newsgroups: microsoft.public.access.tablesdbdesign
From: "Jeff Boyce" <jeff.bo...@courts.wa.gov>
Date: Tue, 12 Sep 2000 10:56:37 -0700
Local: Tues, Sep 12 2000 1:56 pm
Subject: Re: Next number for an Autonumber field
Sometime if you describe WHY you want it, the nice folks here in the
newsgroups have more ideas/suggestions ...

Good luck!

Jeff


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bruce M. Thompson  
View profile  
 More options Sep 12 2000, 2:02 pm
Newsgroups: microsoft.public.access.tablesdbdesign
From: "Bruce M. Thompson" <NO~SPAM_bthmp...@bigfoot.com>
Date: Tue, 12 Sep 2000 14:05:02 -0400
Local: Tues, Sep 12 2000 2:05 pm
Subject: Re: Next number for an Autonumber field
Lee:

If it's important enough, you could always create a new record in code, save
the new autonumber value plus 1 to a variable, and then delete the new
record you just added. It will create another gap in the sequence, but will
ensure that you get the right number even if you deleted records with the
highest existing numbers (leaving a gap before the new record).
--
Bruce M. Thompson
bthmpson@big_NOSPAM_foot.com

"Lee Cartwright" <lee.cartwri...@bull.co.uk> wrote in message

news:e2EyVdLHAHA.195@cppssbbsa04...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
HSherriff  
View profile  
 More options Sep 13 2000, 9:11 am
Newsgroups: microsoft.public.access.tablesdbdesign
From: "HSherriff" <HSherr...@scana.com>
Date: Wed, 13 Sep 2000 09:03:01 -0400
Local: Wed, Sep 13 2000 9:03 am
Subject: Re: Next number for an Autonumber field

Set the query "autonumber" field to sort desending. And set the query TOP
VALUES to 1. This will return the LAST autonumber. Add a calculated field to
the query something like:
NextNumber: [autonumberID] + 1

HTH
Harlan


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bruce M. Thompson  
View profile  
 More options Sep 14 2000, 3:00 am
Newsgroups: microsoft.public.access.tablesdbdesign
From: "Bruce M. Thompson" <NO~SPAM_bthmp...@bigfoot.com>
Date: 2000/09/14
Subject: Re: Next number for an Autonumber field

Harlan:

If no records have been deleted from the table (for argument's sake) and
your last record had an autonumber value of 1000 and you deleted that last
record, the last autonumber would be 999. The next autonumber value would be
1001, not 1000 unless you compacted the file after the deletion. You cannot
depend on the highest existing autonumber value to be a value 1 less than
the next autonumber value.
--
Bruce M. Thompson
bthmpson@big_NOSPAM_foot.com

"HSherriff" <HSherr...@scana.com> wrote in message

news:Oe456MYHAHA.196@cppssbbsa04...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
HSherriff  
View profile  
 More options Sep 14 2000, 3:00 am
Newsgroups: microsoft.public.access.tablesdbdesign
From: "HSherriff" <HSherr...@scana.com>
Date: 2000/09/14
Subject: Re: Next number for an Autonumber field

Bruce,
Good catch......You right (as usual).....
It wasn't till after I pressed that POST button thaat I thought about
deleted records....


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tony Toews  
View profile  
 More options Sep 14 2000, 3:00 am
Newsgroups: microsoft.public.access.tablesdbdesign
From: Tony Toews <tto...@telusplanet.net>
Date: 2000/09/14
Subject: Re: Next number for an Autonumber field

"Lee Cartwright" <lee.cartwri...@bull.co.uk> wrote:
>Is there anyway, within a query, to find out what the next number in an
>incrementing Autonumber field will be?

In a query, no.  In code you can indeed do this.  So whenever I need
to know the just added ID, for example I'm adding child records in a
related table, I use a recordset instead of an append query along with
the following code.

Frequently you have to check to see if a record in a table which
matches certain critieria exists and get its ID number.  If it doesn't
exist you need to add it and then get the ID number.  Use the
following code.
        Dim MyDB As Database, MyTable As Recordset
        Set MyDB = DBEngine.Workspaces(0).Databases(0)
        Set MyTable = MyDB.OpenRecordset("Customers")
        MyTable.AddNew          
        MyTable("Company Name") = "Finnegan's Foods"
        MyTable.Update          
        MyTable.Move 0, MyTable.LastModified    
        CustomerID = MyTable("CustomerID")
        MyTable.Close                  
MyDB.Close
        Set MyTable = Nothing
        Set MyDB = Nothing

Tony
----
Tony Toews, Microsoft Access MVP
   Please respond only in the newsgroups so that others can
read the entire thread of messages.
   Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
   VolStar http://www.volstar.com Manage hundreds or
thousands of volunteers for special events.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »