Quick Search for:  in language:    
simulation,auto,incremtal,field,there,feature
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
Visual Basic Stats

 Code: 3,008,557. lines
 Jobs: 115. postings

 How to support the site

 
Sponsored by:

 

You are in:

 
Login



Latest Code Ticker for Visual Basic.
Click here to see a screenshot of this code!a [CNM1] - CodeXP's Network Messenger
By CodeXP on 6/27

(Screen Shot)

Click here to see a screenshot of this code!Maths
By Sjoerd on 6/27

(Screen Shot)

Search A Listview
By Blue Flame Software on 6/27


Click here to see a screenshot of this code!Visual Basic Source Code into HTML format Converter
By sherif rofael on 6/27

(Screen Shot)

Click here to see a screenshot of this code!INK. Virus Sniffer® Spanish Edition
By INK. Security Products on 6/27

(Screen Shot)

Click here to see a screenshot of this code!INK. Virus Sniffer® Full Version 2
By INK. Security Products on 6/27

(Screen Shot)

Click here to see a screenshot of this code!Repair access database
By Freebug on 6/27

(Screen Shot)

chating with net send
By Freebug on 6/27


Click here to see a screenshot of this code!Different Open Methods
By Hou Xiong on 6/27

(Screen Shot)

Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!





Affiliate Sites



 
 
   

Editable Auto Incremental Field Function

Print
Email
 

Submitted on: 6/21/2003 6:18:45 AM
By: Said Sowiny 
Level: Advanced
User Rating: By 1 Users
Compatibility:VB 5.0, VB 6.0

Users have accessed this article 451 times.
 
(About the author)
 
     this is a simulation of the auto incremtal field but there is a feature it is editable that allowing you to enter the value your self or let the function do so. a nother one is when you delete a record you can enter the deleted value again. this clear in single user interface but in a multi user interface the GetNextID Function Holds a snapshot NextID in seach case a nother GetNextID can generate the same NextID and may result in a dupplicate value in primary fields in adding new or updateing records. this can be resolved by recalling the function untill a valied NextID can be generated. i mean this can be treated by the programer hemself not the function its for you. see Conditional Editable Auto incremental field function version at psc.

 
 
Terms of Agreement:   
By using this article, you agree to the following terms...   
1) You may use this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this article from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the article or article's description.

Public Function GetNextID(ByVal fldname As String, ByVal rstName As String) As Integer

Dim rstNextID As Recordset

Set rstNextID = gdbName.OpenRecordset("SELECT COUNT (" & fldname & ") FROM [" & rstName & "];")

GetNextID = IIf(IsNull(rstNextID.Fields(0)), 0, rstNextID.Fields(0)) + 1

Repeat:

Set rstNextID = gdbName.OpenRecordset("SELECT (" & fldname & ") FROM [" & rstName & "] WHERE (((" & fldname & ")=" & GetNextID & "));")

If rstNextID.RecordCount = 0 Then

GoTo CloseIt

Else

GetNextID = GetNextID + 1

GoTo Repeat

End If

 

CloseIt:

rstNextID.Close

End Function

Typical usage

TxtCustomerID= GetNextID( "CustomerID","Customes")

Where CustomerID is The Field and Customers is the source table

You can enter the value manually also you can enter a deleted value again

Enjoy

 


Other 5 submission(s) by this author

 

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this article(in the Advanced category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments

 There are no comments on this submission.
 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this article has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular article, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | Visual Basic Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.