Loading

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



Hi can i ask favorite.kindly help me to create a courseware proj.what wil be t codes?plz help me

cidfrey's picture

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 ^_^

Web / System Developer
Contacts :
09327081978
recca_flame05@yahoo.com >>> Facebook/YM
ICCT Colleges Cainta Rizal

hi,help me for school management system

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

cidfrey's picture

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

Web / System Developer
Contacts :
09327081978
recca_flame05@yahoo.com >>> Facebook/YM
ICCT Colleges Cainta Rizal

ok....Do me a favour
could you find it for me if it's possible.

Thank u so much for your help..:)

cidfrey's picture

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 ^_^

Web / System Developer
Contacts :
09327081978
recca_flame05@yahoo.com >>> Facebook/YM
ICCT Colleges Cainta Rizal

you can use the recordID(auto numbering) of each record, or generate a sequence of
ID w/ format you like if you can.

cedrick blas's picture

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)

cidfrey's picture

Pwede ko ba ito isalin sa access type database? Uhmm hindi ako marunong sa sql hahaha. Pero try ko pa rin to. Salamat dudes ^_^

Web / System Developer
Contacts :
09327081978
recca_flame05@yahoo.com >>> Facebook/YM
ICCT Colleges Cainta Rizal

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.....

hi...
i am nt gettin code for auto incrementing the service id and it shld display in textbox later service id is submitted to database...cn u plz help me out to solve...

maverickosama's picture

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

www.bitsbyta.com

Thanks Allah For Everything

Add new comment