Assign values in a random order

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a pretty large database, I need to assign a value to new filed like
"A" and "B" in a random order. If I can assign alternate also is fine.
 
If numbers would be OK instead, you could use an autonumber field and change
the default of increment to random.
 
joe said:
I have a pretty large database, I need to assign a value to new filed
like "A" and "B" in a random order. If I can assign alternate also is
fine.

You could use an update query along these lines:

UPDATE YourTable
SET [AorBField] =
IIf(Rnd(IsNull([AorBField])+2) Mod 2=0,"A", "B");

For "YourTable", substitute the name of the table to be updated. For
"AorBField", substitute the name of the field you want to receive the
value "A" or "B". This field must already have been created in the
table design.

Note that, as written, this won't be completely random, as you won't
have executed the VBA Randomize statement to seed the random-number
generator. But from your description, this should be random enough.
 

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

Similar Threads

Random Order of List 3
My boss changed a field - help!! 15
random assignment 0
Generating a Random Number 4
Final Status 1
Auto number 4
Aggregate Function Error 0
Random sorting with restrictions 1

Back
Top