add numeric ID based on Department

  • Thread starter Thread starter PowellGirlTN
  • Start date Start date
P

PowellGirlTN

I have a table to record employees for a small company. I need to assign a
unique numeric ID to each employee based on their deparment. I have the
field DeptID in my table. How can I auto fill numeric values starting with 1
in the field DeptEmplID so it automatically assigns the numeric value for
each person in each department? I appreciate your help, thank you.
 
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.NewRecord Then
Me!DeptEmplID = Nz(DMax("DeptEmplID", "YourTableName"),0) + 1
End If
End Sub
 
Back
Top