January 4, 200224 yr Hi, I'm using the following calcuation to automatically generate a six digit PIN number: Round(Random* 1000000, 0) This calcuation works fine. However, I have noticed that sometimes this calcuation will generate a PIN with ONLY 5 digits (rather than 6.) Q: Is there a better method to calculate a six digit PIN? Thanks.
January 4, 200224 yr I guess you are not considering zero a valid digit? There is nothing to prevent your calculation from returning a 4 or even 3 digit number since the Random function returns a random number between zero and one. How about adding a six digit number to the result and truncating to six digits? Left(Round(Random * 1000000, 0) + 123456, 6) -bd
January 4, 200224 yr The problem with "random" numbers is that they are random. 0 is just as likely as 123456. If you do NOT need to perform heavy mathematical functions on the PIN, then you can make it a Text field as follows: code: Right ( "000000" & NumToText ( Round(Random* 1000000, 0) ), 6) This will generate a 6 digit PIN where leading 0s are OK. It will generate in 000000 to 999999 for the final result. Rememeber that just because you are using integers does NOT mean that the field must be a number.
Create an account or sign in to comment