User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: Aug 2004
Posts: 9
Reputation: MSUMichelle is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
MSUMichelle MSUMichelle is offline Offline
Newbie Poster

Help Autonumbering?

  #1  
Aug 10th, 2004
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*
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2004
Location: Adelaide, Australia
Posts: 191
Reputation: mnemtsas is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 1
mnemtsas's Avatar
mnemtsas mnemtsas is offline Offline
Junior Poster

Re: Autonumbering?

  #2  
Aug 10th, 2004
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,
Reply With Quote  
Join Date: Aug 2004
Posts: 9
Reputation: MSUMichelle is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
MSUMichelle MSUMichelle is offline Offline
Newbie Poster

Re: Autonumbering?

  #3  
Aug 11th, 2004
I apologize, but I am not very good with VBA code. The second option sounds best - would you mind walking me through it a little more? I appreciate it!
*Michelle*
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Visual Basic 4 / 5 / 6 Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum

All times are GMT -4. The time now is 4:21 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC