forms - Making custom primary key for access tables -
i looking way make custom primary keys access tables. looking make 'c01234'. alphabet @ start has purpose , hence has there.
i know there way use autonumbered pk field , make custom field using dmax function. this: custom primary key ms access. looking not use field , generate alpha numeric pk using code.
is possible using access macro? there other way of doing ?
if use form, use beforeinsert event:
dim prefix string dim digits integer prefix = "c" digits = 5 me!customid.value = prefix & right(string(digits, "0") & cstr(val(right(dmax("customid", "yourtable", "customid '" & prefix & "*'"), digits)) + 1), digits)
Comments
Post a Comment