Positive Random Autonumbers

G

Guest

I searched the forum but did not see anything on this exact question. I have
an autonumber field set as the PK in one of my tables. Its set to no
duplicates and random numbers. Is there a way to make the database generate
positive random numbers only. I don't care about the number range just as
long as it does not give me a negative number.

Any help is appreciated.

Thanks.
 
D

Dirk Goldgar

Ray said:
I searched the forum but did not see anything on this exact question.
I have an autonumber field set as the PK in one of my tables. Its set
to no duplicates and random numbers. Is there a way to make the
database generate positive random numbers only. I don't care about
the number range just as long as it does not give me a negative
number.

You can't make the database engine generate positive random autonumbers.
If records will be entered only by a form you design, you could use code
to generate your own positive, random number.
 
R

Rick Brandt

Ray said:
I searched the forum but did not see anything on this exact question.
I have an autonumber field set as the PK in one of my tables. Its set
to no duplicates and random numbers. Is there a way to make the
database generate positive random numbers only. I don't care about
the number range just as long as it does not give me a negative
number.

Any help is appreciated.

Thanks.

What is the reason you don't want negative values? Is it just appearance?
If so you could use random AutoNumbers but convert them to Hexidecimal for
display. That gives you a nice consistent 8 character "value" containing
both letters and digits without a negative sign for the negative values.
 
A

aaron.kempf

if you were using an Access Data Project it would be quite easy to set
seed and identity in order to do this.. you could do triggers that
would do this.. you could use database-side user defined functions

MDB is lame and obsolete
 
D

David F Cox

If an autonumber is unique and you care what value it has you are almost
certainly using it the wrong way.
You want random, use RND(), you want positive use ABS(). you want unique use
NOT IN() or an algorithm..
 

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