View Single Post
  #4 (permalink)  
Old May 13th, 2014, 11:38 AM
Rod Stephens's Avatar
Rod Stephens Rod Stephens is offline
Wrox Author
Points: 3,166, Level: 23
Points: 3,166, Level: 23 Points: 3,166, Level: 23 Points: 3,166, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

Quote:
I hope you would also have time to post an example in your vb-helper web site. Since that website is mainly about the old vb6, why dont you make codes available to VB.Net also. I see that you're writing books for many versions of VB.Net
Unfortunately I haven't had time to maintain the VB Helper site much. That site is probably about 2/3 VB .NET at this point. Unfortunately the VB book market isn't as strong as the C# market so I'm writing mostly C# right now.

I'm attaching an example to this post so you can see how to get a newly inserted auto-number value and how to reset the initial value.

(Note that this can cause problems if you're not careful. In your example it shouldn't, but suppose you reset the initial value to 1. When you then insert a new record, you'll get the value 1. If that value has already been used and if the field requires uniqueness, which a lot of auto-number fields do, then you'll get a duplicate value exception. As I said, this probably won't be a problem for you if you only set it forward each year.)
Attached Files
File Type: zip howto_net_reset_access_autonumber.zip (35.2 KB, 5 views)
__________________
Rod

Rod Stephens, Microsoft MVP

Essential Algorithms: A Practical Approach to Computer Algorithms

(Please post reviews at Amazon or wherever you shop!)
The Following User Says Thank You to Rod Stephens For This Useful Post:
frdata (May 13th, 2014)