VB School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

 

Code Snippets

  

Visual Basic Source Code


You're Browsing As A Guest! Register Now...
Become a VB Expert!

Join 358,485 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 2,186 people online right now.Registration is fast and FREE... Join Now!




Creating Auto Number Generation

creating Auto Number generation in any connection

Submitted By: thava
Actions:
Rating:
Views: 6,873

Language: Visual Basic

Last Modified: October 26, 2008
Instructions: to run this code the connection must support sql Queries and the suto number Field must be an integer data type

Snippet


  1. public function Generate_No( Table_Name as String, Auto_Field_Name as String) as integer
  2. dim con as new connection
  3. dim rs as new Recordset
  4.  
  5. ' write the codding for connection
  6. 'you can use any connection
  7.   rs.open("Select Max(" & Auto_Field_Name & ") from " & Table_Name & ""),con
  8. ' now it will gives the Biggest number
  9. if not rs.eof then
  10.      Generate_No=val(RS(0)) + 1
  11. else
  12.      Generate_No=1
  13. end if
  14. End Function

Copy & Paste


Comments

memon1987 2008-12-10 14:17:01

ok but how can i know i that how many box in programm, tables and cammand button ? pls tell me


Add comment


You must be registered and logged on to </dream.in.code> to leave comments.





Live VB Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month