Refernce Number

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

How can I create a reference number in Access ?? I am
after a unique Random (Positive) number in Access that is
5 digits long that I can use for my Primary Key.

Thanks
J
 
See the Rnd() function in the help file. (Be sure to open the help file from
the VBA editor rather than the main Access window.) To always get 5 digits,
you'll need to convert the number to a string and pad it with leading zeros.
Then query the database to see if a record already exists with that value in
the field. If yes, repeat until you get a value that doesn't already exist.

You realise that you're restricting the table to a maximum of 99,999
records?
 
Back
Top