borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2010 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Recordset \"LIKE\" filter of a number column)Next Topic (MySql and VB) New Topic New Poll Post Reply
AndreaVB Forum : Database : special auto increment value
Poster Message
gcsfamily
Level: Trainee

Registered: 14-07-2009
Posts: 1

Ads by Lake Quincy Media
icon special auto increment value

I'm creating in Visual Basic 2008 with Access Database an application that requires auto number /auto increment number
formatted with last 2 digits of current year plus 00001---I can't find out how to do this. Please can anybody tell me how to do
this?

14-07-2009 at 01:56 PM
View Profile Send Email to User Show All Posts | Quote Reply
GeoffS
Level: VB Lord


Registered: 29-09-2004
Posts: 606
icon Re: special auto increment value

The "Autonumber" type in MS-Access is restricted to a whole integer starting at 1 and incrementing by 1. You cannot change this.
To implement a special identity number you will need to handle it manually. Create a table (NextIdentity) to store the next number to use. Whenever a new record is saved to your main table retrieve the value from the NextIdentity table, Increment the number by whatever criteria you choose and save it back to the NextIdentity table, then insert the retrieved id into the PrimaryKey field of your main table.
If your database is likely to be used in an environment where multiple users are adding lots of new records then you would be wise to check for the existence of the id in the main table before inserting it, just incase you have retrieved the NextIdentity before another user who has also retrieved that identity has saved the increment back.


____________________________
multi-tasking - the ability to hang more than one app. at the same time.

Ads by Lake Quincy Media
23-07-2009 at 10:41 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : Database : special auto increment value
Previous Topic (Recordset \"LIKE\" filter of a number column)Next Topic (MySql and VB) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2010 Andrea Tincaniborder