Hello guys,this is sample code on how you to generate a Auto-Generated ID Number or a
Primary Key, because many programmers like me are want the ID Number or Primary Key
become Dynamic, so we can do the basic solution like this:
Primary Key, because many programmers like me are want the ID Number or Primary Key
become Dynamic, so we can do the basic solution like this:
In my case i put it on a Sub Procedure that i placed it on a Module,so the this is the Code:
Sub EmployeePosition_ID()
Set rs=New Adodb.Recordset
If rs.State = adStateOpen Then rs.Close
rs.Open "SELECT MAX (right(Position_ID,6)) _
from EmployeePositions", Conn
If rs.EOF <> True Then
Employee_Positions.txtID.Text = "SPC" + "-"
+ Right("000000" _
+ Right("000000" _
& IIf(IsNull(rs.Fields(0)), 1, rs.Fields(0) + 1), 6)
End If
End Sub
How does it Works??
5 Comments










