vendredi 7 septembre 2018

Generating Incremental (or Random without duplicated data) Numbers from a randomly generated number within an Access Calculated Query Field

Objective: I need an Access Query to randomly generate 3-digit numbers that are used to create a unique serial number for all serial numbers generated on a specific date. Half of the serial number is generated via the ship date, and therefore the 3-digit value must be completely unique for the set of records returned (could be up to 100 records for a given day).

To generate a random number, I am using the following function:

Int((900-100+1)*Rnd()+100)

This function generates the number randomly between 100 and 900 for the first record returned in the query. The problem is that each record below that 1st record contains the same number, hence creating duplicated serial numbers for each record returned in the query.

What I need is to either implement an increment function that can increase the value of the original randomly generated number by 1, or create syntax that tells Access to randomly generate numbers without the 100-900 range for all records returned without the possibility of a duplicate number assigned.

Thank you SO MUCH in advance for the help!

Erik




Aucun commentaire:

Enregistrer un commentaire