January 30, 200322 yr I there a way I can have a random alpha numeric code generated in filemaker whenever I create a new record...
January 30, 200322 yr 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
January 30, 200322 yr 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.
January 30, 200322 yr 5 + (Random * 5) yes, but this is numeric... I think Andrew's looking for something Alphanumeric, like 7G98ASDF98S
January 31, 200322 yr 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.
January 31, 200322 yr 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).
Create an account or sign in to comment