Random Generate Range of numbers

  • Thread starter edisonl via AccessMonster.com
  • Start date
E

edisonl via AccessMonster.com

Hi,

My UserID(Primary Key) being set as text in its data type.

So on create of new records UserID consist of YearYearMonthMonth (Current
Year & Month of Creation) + 2 Digit Random numbers from 0 to 99. Is it
possible ?

For the Text to Numbers conversion I had no worries, the issue is how to
explicits let Access generate numbers from 1 to 99 ?

Regards, Edison
 
E

EMonk

On Feb 24, 2:25 pm, "edisonl via AccessMonster.com" <u47544@uwe>
wrote:
For the Text to Numbers conversion I had no worries, the issue is how to
explicits let Access generate numbers from 1 to 99 ?

From the Access help file on the Rnd function:

| To produce random integers in a given range, use this formula:
|
| Int((upperbound - lowerbound + 1) * Rnd + lowerbound)


So for your purposes you might have something similar to:

UID = Format(Date(), "YYMM") & Format(Int(99 * Rnd() + 1), "00")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top