Snip..
>>First I wouldn't suggest recno() as a PK. Assuming still you want it :
Snip..
>>Cetin
>
>Here's another method I've used. The advantage is that you don't have to do extra record locking and keep track of last-used ID's. The disadvantage is that you don't get sequential numbers.
>
>Store julian date or year+month+day in the order number field. Then add the 24-hour time with seconds. The format would be YYYYMMDDHHmmSS. If you're indexed on this field, everything will be in date/time order. If you have a lot of users, you may want to add a couple of digits from the random number generator, Rand(), to avoid two people hitting the Enter key at the same second.
>
>But, If you need sequential numbers or need to follow an existing format, you can't use this method.
>
>Allen
Hi Allen,
Of course this is better. To shorten it and directly use as a default value you could use sys(2015). It would give a 10 char unique value for a given station and would be unique even called via a program :
v1 = sys(2015)
v2 = sys(2015)
v3 = sys(2015)
? v1,v2,v3
It's based on system datetime. So unless the datetime of computer is set to a previous datetime, there is no chance to get a duplicate on a given computer. For multiple computers on a LAN, fortunately network card addresses are unique, and they are represented in 12 bytes. So sys(2015)+netcardaddress would ensure a unique key on a LAN.
BTW: You could get netcardaddress via WinAPI but don't know the function. I use my own asm routine.
Cetin