•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Visual Basic 4 / 5 / 6 section within the Software Development category of DaniWeb, a massive community of 456,528 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,752 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums
Views: 3018 | Replies: 2
![]() |
•
•
Join Date: Aug 2004
Posts: 9
Reputation:
Rep Power: 0
Solved Threads: 0
I am working in MS Access 2000 and trying to have the computer continue an ID pattern I have. Right now I have a table with a field "Customer Program ID". There are currently 5 of them...CP001, CP002, CP003, CP004 and CP005. When the user selects new record I would like it to automatically fill in the next available ID...however, I am new to code and I am not sure how to do this. Any help you can provide would be appreciated!
*Michelle*
*Michelle*
•
•
Join Date: Jul 2004
Location: Adelaide, Australia
Posts: 191
Reputation:
Rep Power: 5
Solved Threads: 1
•
•
•
•
Originally Posted by MSUMichelle
I am working in MS Access 2000 and trying to have the computer continue an ID pattern I have. Right now I have a table with a field "Customer Program ID". There are currently 5 of them...CP001, CP002, CP003, CP004 and CP005. When the user selects new record I would like it to automatically fill in the next available ID...however, I am new to code and I am not sure how to do this. Any help you can provide would be appreciated!
*Michelle*
There's a couple of ways I can think to do this.
1.
I'd have a time stamp field containing the datetime a record was added in the table to enable you to select the most recently added record. You can then use some VBA to parse out the most recent ID and create a new one. Trouble with this method is that if you delete the most recent record you will repeat a number.
2. The other way is to have a separate table containing a single INTEGER and simply increment the integer when you add a record to the main table. You can use the value in the table to cat together your unique ID. The strength of this method is that you wont repeat a number if the most recent record happens to be deleted. I'm sure this could be done with straight SQL but I'd do it in VBA, it's pretty trivial.
Cheers,
Mark Nemtsas
Time and Billing Software - Time Tracking Software - Roller Shutters - Roller Blinds -
Baby Books
Time and Billing Software - Time Tracking Software - Roller Shutters - Roller Blinds -
Baby Books
![]() |
•
•
•
•
•
•
•
•
DaniWeb Visual Basic 4 / 5 / 6 Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Urgently need help in getting Autonumbering ID. Thanks Alot. (Visual Basic 4 / 5 / 6)
- Autonumbering in Excel (Windows Software)
- HELP! Need someone that Knows SQL to tell Me How to Access a Primary Key (C)
- Primary Key Issue (Visual Basic 4 / 5 / 6)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: How to list the record orderby id when selecting distinct
- Next Thread: Message boxes


Linear Mode