Jumat, 22 Juli 2011

Re: [MS_AccessPros] Random Select

 

you're welcome, Mike ;)

I meant to say:
UPDATE [tablename] SET [tablename].Ordr = Rnd([numberField]);

warm regards,
Crystal

(: have an awesome day :)

--- On Fri, 7/22/11, mithomas48 wrote:

> Crystal - Thanks so much!
>
>
> Crystal <strive4peace> wrote:
> >
> > Hi Mike,
> >
> > I have a sample database with a form where you can
> pick any table or query and choose a random record here:
> >
> > http://tech.groups.yahoo.com/group/MS_Access_Professionals/files/Crystal/
> >
> > then
> >
> > DB_RandomPicker_Crystal_110416_630p__ACCDB.zip
> >
> > to randomly order them, it would be easiest to create
> a field that you update with the random value
> >
> > for instance, create this field:
> >
> > Ordr, number (double)
> >
> > then this update query:
> > UPDATE [tablename] SET t_People.Ordr =
> Rnd([numberField]);
> >
> > WHERE
> > numberField is, ideally, a numeric unique field in the
> table
> >
> > then sort by Ordr
> >
> > you can also do this
> >
> > SELECT field1, field2, field3
> > FROM tablename
> > ORDER BY Rnd([numberField]);
> >
> > realize that if you do the last method and show the
> random numbers, they will not appear in order ... but they
> will be random ;) ... but you will not be able to get the
> same order again -- so if you need to see the same result in
> the future, create the Ordr field.
> >
> > called it Ordr since OrdEr is a reserved word
> >
> > warm regards,
> > Crystal
> >
> > (: have an awesome day :)
> >
> >
> >
> > --- On Thu, 7/21/11, mithomas48 wrote:
> >
> >
> > > Is there a way to randomly select
> > > records within a recordset using an SQL Select
> > > statement?  The objective is, we are pulling a
> set of
> > > records that meet certain criteria, but want to
> select a
> > > specified number of those records randomly.  So
> > > basically, let's say we have 500 records in the
> > > recordset.  We want to randomly order these
> > > records.  Is there a way to randomly order a
> > > recordset?
> > >
> > > Thanks in advance!
> > > Mike
> > >
> >
>
>

__._,_.___
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar