I agree it's not a good idea to keep multiple info in one field. In
this case the primary key is EMPLID in tbl_Person. It is an 11
character text field, though it is almost always an 8 digit number.
This is assigned by the organization. For other people kept in this
table who are not employees and do not have an organization assigned
EMPLID, I need to assign a unique code that cannot match any existing
EMPLID. To do that I want to concatenate text with the autonumber into
a new field, let's say: NoEMPLID_001. I can't use just the autonumber
because there is a small chance that it could match an exsiting EMPLID.
Don't use an Autonumber for this purpose, then. It's not controllable.
What you could do is maintain your own programmatically assigned ID.
If (as I gather) you can safely use NoEMPLID as a prefix, and be sure
that it will not conflict with any present or future company-assigned
ID's, you could use code like
Dim strID As String
Dim iID As Integer
' get the largest existing non-employee ID
strID = DMax("[EMPLID]", "[tbl_Person]", "[EMPLID] LIKE 'NoEMPLID_*'")
' extract the integer portion
iID = Val(Right(strID, 3))
If iID = 999 Then
MsgBox "Too many non employees, send this one home", vbOKOnly
Me.EMPLID = NULL
Else
Me.EMPLID = "NoEMPLID_" & Format(iID + 1, "000")
End Ef
to assign a new sequential ID. You might want to omit the underscore
and use four digits, just in case.
John W. Vinson[MVP]