-----Original Message-----
what i mean is that the key has prefix.but the numerals
are actually running order numbers.
For eg, my company is Apple and the dept name is HR
So, my auto-pri-key would be called Apple-HR-001
and 001 would be the 1st record.
subsequent record will be automatically generated by
automatically as
Apple-HR-001
Apple-HR-002
Apple-HR-003 etc
This is called an "Intelligent Key". That's not a compliment.
Storing data redundantly in two fields (your Company field and your ID
field, your Department field and your ID field) is a bad idea; storing
multiple different kinds of data in a single field is even worse!
I'd suggest that - if you need this number for compatibility with an
existing paper system - that you do NOT construct this composite field
at all, in your table. Instead you can use the *three* fields
(Company, Dept, and an Integer field SeqNo) as a three- field composite
key, and concatenate them in a Query for display purposes:
IDNum: [Company] & "-" & [Dept] & "-" & [SeqNo]
To increment SeqNo, you'll need to do all your data entry using a
Form; table datasheets don't have any usable events. In the Form's
BeforeUpdate event put code like
Me!txtSeqNo = NZ(DMax("[SeqNo]", "[your- table]", "[Company] = """ &
Me!txtCompany & """ AND Dept = """ & Me!txtDept & """")) + 1
.