Skip to main content

How to do Auto Increment Employee / Student ID

This is one of my professor's requirement on my thesis. I want to know how to give employee / student its number automatically. This is my code Private Sub cmdSave_Click() rs(0) = txtNo.Text rs(1) = txtName.Text rs(2) = txtCity.Text rs(4) = txtDob.Text rs(3) = txtPhone.Text rs(5) = Combo1.Text rs(6) = Combo2.Text rs(7) = Combo3.Text rs(8) = Combo4.Text rs(9) = Combo5.Text rs(10) = Combo6.Text rs.Update MsgBox "The record has been saved successfully.", , "ADD" cmdFirst.Enabled = True cmdLast.Enabled = True cmdNext.Enabled = True cmdPrevious.Enabled = True cmdDelete.Enabled = True cmdUpdate.Enabled = True cmdSave.Enabled = False cmdSave.Visible = False cmdAdd.Enabled = True cmdAdd.Visible = True Command1.Visible = True Command1.Enabled = True Command2.Enabled = True Command3.Visible = False 'for refresh list Adodc1.Refresh txtNo.Text = rs(0) txtName.Text = rs(1) txtCity.Text = rs(2) txtDob.Text = rs(4) txtPhone.Text = rs(3) Combo1.Text = rs(5) Combo2.Text = rs(6) Combo3.Text = rs(7) Combo4.Text = rs(8) Combo5.Text = rs(9) Combo6.Text = rs(10) 'disabling the fields txtNo.Enabled = False txtName.Enabled = False txtCity.Enabled = False txtDob.Enabled = False txtPhone.Enabled = False Combo1.Enabled = False Combo2.Enabled = False Combo3.Enabled = False Combo4.Enabled = False Combo5.Enabled = False Combo6.Enabled = False End Sub Hoping for a positive response I know some of you guys know this so please share it ^_^ hehehe
Submitted byAnonymous (not verified)on Tue, 02/23/2010 - 22:52

Hi can i ask favorite.kindly help me to create a courseware proj.what wil be t codes?plz help me
Submitted bycidfreyon Wed, 02/24/2010 - 23:24

In reply to by Anonymous (not verified)

I think I found what you want here in the site but I'm not sure what is the name of the project. Just look for it ^_^
Submitted bychetan khatri (not verified)on Mon, 02/27/2012 - 20:26

In reply to by Anonymous (not verified)

hi,help me for school management system
Submitted byBeenaon Thu, 02/25/2010 - 15:17

Pls. help i want payroll management system in language C#.

I don't use and C# ma'am. Only VB6 ^_^

Just type on the search engine what you are looking for then all the list will be on your screen ^_^. Got lots of work to do ^_^
Submitted byAnonymous (not verified)on Thu, 02/25/2010 - 22:36

In reply to by cidfrey

you can use the recordID(auto numbering) of each record, or generate a sequence of ID w/ format you like if you can.
Submitted bycedon Fri, 02/26/2010 - 11:37

kung kasi autonumber ung gagamitin mo baka di magkasunod sunod if ever na mag delete ka ng isang record w/c is bad. so naisip ko depende sa mask or fomat na gagamitin mung automatic number for student :) gamit ka sql dre tos sort by ASC then +1 e.g. 1. select studentId from tblstudents order by studentid ASC 2. select for the last index w/c is the highest student number (sql) 3. the lastindex(highest number) + 1 something like this: Dim student_number as String Dim theValue as integer student_number = "SELECT MAX(column_name) FROM table_name" (execute the SQL) 'then capture the value thevalue = val(student_number)+1 'display txtstudentnumber.text = thevalue (try mo idea ko yan dikopa nacocompile peu tama sa isip ko hehehe)

Pwede ko ba ito isalin sa access type database? Uhmm hindi ako marunong sa sql hahaha. Pero try ko pa rin to. Salamat dudes ^_^
Submitted bymy name (not verified)on Sun, 11/24/2013 - 20:25

In reply to by cidfrey

depende kuya..kasi iba ang access sa sql..kya bka di magtugma
Submitted byAnonymous (not verified)on Thu, 06/30/2011 - 08:25

can u teach me how to use sql because i want to lan my database so that other computer can also access my records? plz... im leomar an IT 3rd year student.....

let suppose your SQL db Table is Bill and its column is ID then you can auto-increment ID by 1. see below code written in VB.NET: Private Sub GetAutoID() Dim con = New SqlConnection con.Open() Dim query As String = "Select IsNULL(Max(ID+1), 0) ID from Bill" Dim dr As SqlClient.SqlDataReader Dim cmd As New SqlCommand(query, con) dr = cmd.ExecuteReader dr.Read() txt_billno.Text = dr("ID").ToString End Sub
Submitted byhi (not verified)on Sun, 11/24/2013 - 20:33

hi. am using vb6 for my project.. ngayon po gsto ko pong ma increase ung number sa employee id every time na isasave ko po...meron na akong nagawang code e2 po ung code. txtid.text= val(txtid.text) + 1 pero every time na ieend ko ang program at irrun ko back to zero ulit..pano po un? eh ang gsto ko po ay mag stay ung id number at ready to add na po sya...bale po automatic nandun na ung new id number ng access ang gamit ko pong database..
Submitted byJDC (not verified)on Fri, 03/21/2014 - 14:30

Private Sub generateid() Set rs = New ADODB.Recordset rs.Open "SELECT * FROM table_leave", cn, adOpenStatic, adLockOptimistic If rs.EOF = False Then txtcode.Text = rs.RecordCount + 1 End If End Sub Call generateid to add buttons or save before the statement
Submitted bySUBRATA MANDAL (not verified)on Sun, 11/29/2015 - 15:12

Dim countrs As ADODB.Recordset
Dim count As Integer
Set countrs = New ADODB.Recordset
countrs.Open "Select CustomerId from tblcustomeridgenerate", con, adOpenKeyset, adLockPessimistic
count = countrs.RecordCount
count = count + 1
i = UCase(Left(txtfirstname.Text, 1))
j = UCase(Left(txtlastname.Text, 1))
k = UCase(Left(txtaddress.Text, 1))
m = UCase(Left(rs.Fields(0), 1))
l = Right(txtmobileno.Text, 6)
txtcidgenerate.Text = i + j + k + m + l & count

Submitted byAnonymous (not verified)on Tue, 03/02/2021 - 16:23

  1. count = countrs.RecordCount
  2. count = count + 1
  3. i = UCase(Left(txtfirstname.Text, 1))
  4. j = UCase(Left(txtlastname.Text, 1))
  5. k = UCase(Left(txtaddress.Text, 1))
  6. m = UCase(Left(rs.Fields(0), 1))
  7. l = Right(txtmobileno.Text, 6)
  8. txtcidgenerate.Text = i + j + k + m + l & count

Add new comment