I would like account number to be a 4 digit Number and every time one
is created i would like it a random number as long as that number has
not already been used
I just do not like the idea of giving Cusomer 0001, 0002, as it does
not look like we have been in business long, would like random number
like 5849, 2179, 0485, ect
How would i do this in access
Graham R Seach - 17 May 2007 12:01 GMT
Simon,
Make the Customer table's primary key an AutoNumber datatype, and set it's
NewValues property to Random.
Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
>I would like account number to be a 4 digit Number and every time one
> is created i would like it a random number as long as that number has
[quoted text clipped - 5 lines]
>
> How would i do this in access
BruceM - 17 May 2007 12:21 GMT
Why not just start at 5000 or something? If customers are going to make
assumptions based on their account number, they will do so for a number such
as 0021 whether it is generated randomly or sequentially.
Having said that, take a look at the Rnd function. If you do a Google
groups search for "microsoft public access random number" you will find a
lot of discussion about this very topic. In general you could use something
such as:
Me.AccountNum = Format(Rnd() * 10000,"0000")
>I would like account number to be a 4 digit Number and every time one
> is created i would like it a random number as long as that number has
[quoted text clipped - 5 lines]
>
> How would i do this in access