Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 30th, 2005, 11:59 PM
Registered User
 
Join Date: Jan 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help Needed in Autonumber!

Hi All,

I have Access 2000 Database. In my table, I allocated the first column(Index Number) as autonumbering format with incremental mode. How can I limit my database starting from index number 10 to 99? I need to limit the field to only 2 digit only. Hence, from 99, it will go back to 10 and not zero. Please help.

Rgds,

James

 
Old January 31st, 2005, 09:42 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

You can't reuse index numbers. They must all be unique, so you can't run from 10 to 99, and then back to 10 and start over.

If you are trying to do this in another field, then you can work this out with code. But since the Primary Key must be unique, this will never happen the way you want here.

mmcdonal
 
Old January 31st, 2005, 02:08 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Autonumbers are not meant to be used for any reason other than tagging a record with a unique index. Therefore, if you "need" a number "to be something" you should create a field for it that's not an autonumber field and populate its value with code, e.g. an AfterUpdate event.



Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old February 3rd, 2005, 03:52 PM
Registered User
 
Join Date: Feb 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Just out of curiosity, why are you going from 10 to 99 and back to 10 again?

You could have your 10-99 value propegated based off of the autonumber. For example, the mod operator (AKA modulus) can be used to transform your data. The formula below will return an integer 10-99:

result = ([AutoNumberField] Mod 90) + 10

MOD is a function available in the query expression builder, and you can also use it in code (VBA).

Regards,

Bonnie






Similar Threads
Thread Thread Starter Forum Replies Last Post
Refreshing AutoNumber kuznickic Access VBA 3 February 12th, 2007 08:40 AM
Autonumber Query Brendan Bartley Access 2 July 16th, 2006 02:14 AM
Autonumber in a dataset namellac VB.NET 2002/2003 Basics 0 January 13th, 2005 06:23 PM
regarding Autonumber... MuthuAL Classic ASP Databases 2 December 8th, 2004 08:04 AM
Access Autonumber chall90909 Access ASP 1 November 21st, 2004 10:26 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.