RANDBETWEEN like function in Access calculated query field (1 Viewer)

world33

Registered User.
Local time
Today, 12:49
Joined
Oct 24, 2006
Messages
21
Hello,

Is there any module, function, expression or other way to mimic an Excel RANDBETWEEN function in a MS Access calculated query field?
I read that it is possible to use Excel functions in Access but my level is too basic to be able to apply that option.
I am looking for a query expression that allows me to randomly choose a text value. For example:
RANDBETWEEN(Founded in, Established in) or RANDBETWEEN(located in, situated in, etc.).
Any idea or workaround to achieve that?

Thanks for any help.

world33
 

June7

AWF VIP
Local time
Yesterday, 18:49
Joined
Mar 9, 2014
Messages
5,493
Access VBA has RND function which returns a random number. It can be used in query or VBA. Use it in conjunction with RANDOMIZE function in VBA.
 

world33

Registered User.
Local time
Today, 12:49
Joined
Oct 24, 2006
Messages
21
Access VBA has RND function which returns a random number. Use it in conjunction with RANDOMIZE function.

Emulating the Excel RANDBETWEEN function will involve writing custom function in VBA.
Thanks. How Do I combine them to generate random text?
 

June7

AWF VIP
Local time
Yesterday, 18:49
Joined
Mar 9, 2014
Messages
5,493
Apparently I edited my previous post after you read it.

What kind of text do you want - a single character?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 10:49
Joined
May 7, 2009
Messages
19,246
somewhere i get this:

Code:
Public Function RandBetween(Optional Lowest As Long = 1, Optional Highest As Long = 9999)
' Generates a random whole number within a given range
   Randomize (Timer)
   RandomNumber = Int(Rnd * (Highest + 1 - Lowest)) + Lowest
End Function
you can only pass numeric value.
use PK field and Dlookup() its value to generate
a Random String.
 

Users who are viewing this thread

Top Bottom