tallboy755 Posted January 30, 2003 Posted January 30, 2003 I there a way I can have a random alpha numeric code generated in filemaker whenever I create a new record...
Lee Smith Posted January 30, 2003 Posted January 30, 2003 There are some tip files availabe at www.fmfiles.com, www.databasepros.com and www.dwdataconcepts.com that might help you. Do a search for random should do it. HTH Lee
danjacoby Posted January 30, 2003 Posted January 30, 2003 Have the field auto-enter a calculated result. In the calculation, use the "random" function. This returns a number between zero and one. You can then multiply this by your maximum value, as well as adding or subtracting if necessary. For instance, to generate a random number between 5 and 10, use: 5 + (Random * 5) Et voila.
jasonwood Posted January 30, 2003 Posted January 30, 2003 5 + (Random * 5) yes, but this is numeric... I think Andrew's looking for something Alphanumeric, like 7G98ASDF98S
BobWeaver Posted January 31, 2003 Posted January 31, 2003 For alphanumeric, define a global text field called gCharSet and set it equal to: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" Then you can create an auto enter field with this formula: Middle(gCharSet,Int(Random*36)+1,1)& Middle(gCharSet,Int(Random*36)+1,1)& Middle(gCharSet,Int(Random*36)+1,1)& Middle(gCharSet,Int(Random*36)+1,1)& Middle(gCharSet,Int(Random*36)+1,1)& Middle(gCharSet,Int(Random*36)+1,1)& Middle(gCharSet,Int(Random*36)+1,1) etc.
tallboy755 Posted January 31, 2003 Author Posted January 31, 2003 That Worked ...... WOW..... How do you do that ....
jasonwood Posted January 31, 2003 Posted January 31, 2003 How do you do that .... Middle(gCharSet,Int(Random*36)+1,1) Random * 36 generates a random number between 0 and 36. This is so because Random generates a number between 0 and 1, so when you multiply it by something, it increases the spread. Int() then changes it to an integer (drops anything after the decimal). Then you add 1 because you want a range of 1-36, not 0-35. Then the middle function takes the above place in the field gCharSet. So if you set your field to Middle(gCharSet,Int(Random*36)+1,1), it will take one random character from gCharSet. Doing it multiple times separated by &'s allows you to have multiple characters (as many as you wish).
Recommended Posts
This topic is 8037 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