beenet Posted January 4, 2002 Posted January 4, 2002 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.
LiveOak Posted January 4, 2002 Posted January 4, 2002 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
Kurt Knippel Posted January 4, 2002 Posted January 4, 2002 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.
Recommended Posts
This topic is 8611 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now