G Guest Apr 4, 2007 #1 How to populate a field with a four digit random number when new record is added (similar to RANDBETWEEN function in Excel)?
How to populate a field with a four digit random number when new record is added (similar to RANDBETWEEN function in Excel)?
G Guest Apr 4, 2007 #2 I don't think there's a built in function for it in Access, but you can always create a function in VB and use it wherever you wanted. Function fRandom(LowNumber As Double, HiNumber As Double) As Integer fRandom = Int((HiNumber - LowNumber) * Rnd + LowNumber + 1) End Function Then use =fRandom(1000,9999) as your default value. It's much easier to just use the random AutoNumber type for the field, but it won't limit it to a 4 digit number.
I don't think there's a built in function for it in Access, but you can always create a function in VB and use it wherever you wanted. Function fRandom(LowNumber As Double, HiNumber As Double) As Integer fRandom = Int((HiNumber - LowNumber) * Rnd + LowNumber + 1) End Function Then use =fRandom(1000,9999) as your default value. It's much easier to just use the random AutoNumber type for the field, but it won't limit it to a 4 digit number.