creating random numbers

  • Thread starter Thread starter Elisa
  • Start date Start date
E

Elisa

Hello everybody
I am using microsoft access 2000, and I can't create in a form, for a
new record, a random number as predefined value which is different
from all the random numbers already created for the existing records
(that means that if the formula generates a random number which
already exists, it realise that this number already exists and
regenerate another one)

can anyone help me? thanks a lot
Elisa
 
The problem is that I already have an existing field, whose datatype
is number, and it contains numbers I must preserve (It is a field for
passwords and the passwords already assigned can't be changed), and
access doesn't permit to change the datatype from number to
autonumber.
how can I do? Thanks

Elisa
 
Create a new table with the same data structure (no data) as your existing
table. Then change the data type of the field you want to autonumber set to
random. Then create an append query that will every field (including the
field that in an autonumber in the new table) to this new table. All your
original random numbers will be preserved and new numbers will be random.

Kelvin
 
yes it works!
but the new numbers it generates are also negative and are too big for
the field. The field is for password, and should be more or less
between 5 and 7 digit (10000 and 9999999.
As for random autonumber field I cannot set neither the lenght nor the
sign of the number, I was wondering if there is a routine in VBA for
which I can:
- set the field as "number", which is the primary key of the table
- put in the predefined value a formula that creates random numbers
(which I have)
- create a routine in VBA that regenerates the number if the number
generated already exists.

I cannot write this routine, how can it be? Should I write it in the
form, as an event?
 
Do the passwords need to be unique to each other? If you just need a random
number, there is a random number generator that can be used. The problem is
that there is a chance (although slim) that this number may be repeated.
Since you are generating passwords that I assume are also linked to a user
ID, having repeated passwords might not be a problem. Would this work?

Kelvin
 
Back
Top