|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Generate primary key
Hi,
I'm designing a small database for a friend and they would like to have the primary key to auto increment and have a prefix ie mhh 0001, mhh0002, mhh0003 etc .Can this be done with access? Cheers |
|
#2
|
||||
|
||||
|
Can be done, but it's a bit more difficult than ones would think.
You need to have an AutoNumber field to generate the number, and you need a code that concatenates your constant string and the number captured from the AutoNumber field. If you wish the PK value to be padded with leading zeros then you need to determine the length of the number returned by the AutoNumber field. Eg. if your AutoNumber is 1 then you need three zeros, if your AutoNumber is 125 then you need one zero if you wish the PK to be the same length. Think about this, however, if it's important to have this format of PK.
__________________
BRegs, TBÁrpi "I can only show you the door. You're the one who has to walk through it." |
|
#3
|
|||
|
|||
|
Many thanks for the good advice.
|
|
#4
|
|||
|
|||
|
Found this little database that might get you into the right area.
Regards, Dino |
|
#5
|
||||
|
||||
|
Very nice, thanks.
|
![]() |
| Viewing: ASP Free Forums > Database > Microsoft Access Help > Generate primary key |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|