Getting a from to show random results

Getting a from to show random results

Post by mett » Fri, 15 Dec 2000 23:52:03



I have a problem, I need to display a random result (one) from a table of 25
possibles.

My query will give a random selection from a table by inserting;

Int((upperbound - lowerbound + 1) * Rnd + lowerbound)

Each time I run the query I get a random result. Great, except I need to
display the results in a form and on the Web and of course it just keeps
showing the same record!

Database is small (25 records) How do I get the record to change when the
form is reloaded or the web page is refreshed etc. Not a novice but
defiantly not even remotely an expert!

M

 
 
 

Getting a from to show random results

Post by Wayne Michae » Sat, 16 Dec 2000 00:00:19


you need a

randomize timer

this sets a seed


>I have a problem, I need to display a random result (one) from a table of
25
>possibles.

>My query will give a random selection from a table by inserting;

>Int((upperbound - lowerbound + 1) * Rnd + lowerbound)

>Each time I run the query I get a random result. Great, except I need to
>display the results in a form and on the Web and of course it just keeps
>showing the same record!

>Database is small (25 records) How do I get the record to change when the
>form is reloaded or the web page is refreshed etc. Not a novice but
>defiantly not even remotely an expert!

>M


 
 
 

Getting a from to show random results

Post by mett » Sat, 16 Dec 2000 00:11:46


Thanks, but How do I do this in a simple table, query or whatever?

M

--

http://www.metta.co.uk  Worth a pre launch visit


> you need a

> randomize timer

> this sets a seed


> >I have a problem, I need to display a random result (one) from a table of
> 25
> >possibles.

> >My query will give a random selection from a table by inserting;

> >Int((upperbound - lowerbound + 1) * Rnd + lowerbound)

> >Each time I run the query I get a random result. Great, except I need to
> >display the results in a form and on the Web and of course it just keeps
> >showing the same record!

> >Database is small (25 records) How do I get the record to change when the
> >form is reloaded or the web page is refreshed etc. Not a novice but
> >defiantly not even remotely an expert!

> >M

 
 
 

Getting a from to show random results

Post by Wayne Michae » Sat, 16 Dec 2000 00:34:59


Maybe I don't fully understand what you are trying to do.

the randomize timer uses the timer to generate different random numbers.

Now in your query,  You will have to build a random where clause.

ie

let sql = "select * from mytable where indexfields = " + Int((upperbound -
lowerbound + 1) * Rnd + lowerbound)


>Thanks, but How do I do this in a simple table, query or whatever?

>M

>--

>http://www.metta.co.uk  Worth a pre launch visit



>> you need a

>> randomize timer

>> this sets a seed


>> >I have a problem, I need to display a random result (one) from a table
of
>> 25
>> >possibles.

>> >My query will give a random selection from a table by inserting;

>> >Int((upperbound - lowerbound + 1) * Rnd + lowerbound)

>> >Each time I run the query I get a random result. Great, except I need to
>> >display the results in a form and on the Web and of course it just keeps
>> >showing the same record!

>> >Database is small (25 records) How do I get the record to change when
the
>> >form is reloaded or the web page is refreshed etc. Not a novice but
>> >defiantly not even remotely an expert!

>> >M

 
 
 

Getting a from to show random results

Post by mett » Sat, 16 Dec 2000 01:37:16


Hi and thanks for trying to help.

OK perhaps I should explain a little. Database has 25 records and I would
like to display 1 record at random.
The query contains:

Int((25-1+1)*Rnd()+1)

This displays one random record when I run the query. If I then display this
query in a form it works too however when I try to use this same query on a
web page the same record keeps coming up? (Front Page 2000 + Access 97)

Thanks if you can help with this problem.

M


> Maybe I don't fully understand what you are trying to do.

> the randomize timer uses the timer to generate different random numbers.

> Now in your query,  You will have to build a random where clause.

> ie

> let sql = "select * from mytable where indexfields = " + Int((upperbound -
> lowerbound + 1) * Rnd + lowerbound)


> >Thanks, but How do I do this in a simple table, query or whatever?

> >M

> >--

> >http://www.metta.co.uk  Worth a pre launch visit



> >> you need a

> >> randomize timer

> >> this sets a seed


> >> >I have a problem, I need to display a random result (one) from a table
> of
> >> 25
> >> >possibles.

> >> >My query will give a random selection from a table by inserting;

> >> >Int((upperbound - lowerbound + 1) * Rnd + lowerbound)

> >> >Each time I run the query I get a random result. Great, except I need
to
> >> >display the results in a form and on the Web and of course it just
keeps
> >> >showing the same record!

> >> >Database is small (25 records) How do I get the record to change when
> the
> >> >form is reloaded or the web page is refreshed etc. Not a novice but
> >> >defiantly not even remotely an expert!

> >> >M

 
 
 

Getting a from to show random results

Post by Wayne Michae » Sat, 16 Dec 2000 01:41:09


This is kind of a guess...

When you use rnd function,  and you do not give it a seed,  it will generate
random numbers just fine.

but if you stop the execution of the program and restart it,  it will give
you the same numbers in the same order.

You can avoid this by planting a seed

function x()
    randomize timer
    x = Int((25-1+1)*Rnd()+1)

end sub

since your web page is reloading each time,  it might be like restarting
your application..

here is a idea. Make a second web page and put two random query's in it.
see if you get the same result that way..

Hope this helps.

Wayne


>Hi and thanks for trying to help.

>OK perhaps I should explain a little. Database has 25 records and I would
>like to display 1 record at random.
>The query contains:

>Int((25-1+1)*Rnd()+1)

>This displays one random record when I run the query. If I then display
this
>query in a form it works too however when I try to use this same query on a
>web page the same record keeps coming up? (Front Page 2000 + Access 97)

>Thanks if you can help with this problem.

>M



>> Maybe I don't fully understand what you are trying to do.

>> the randomize timer uses the timer to generate different random numbers.

>> Now in your query,  You will have to build a random where clause.

>> ie

>> let sql = "select * from mytable where indexfields = " +
Int((upperbound -
>> lowerbound + 1) * Rnd + lowerbound)


>> >Thanks, but How do I do this in a simple table, query or whatever?

>> >M

>> >--

>> >http://www.metta.co.uk  Worth a pre launch visit



>> >> you need a

>> >> randomize timer

>> >> this sets a seed


>> >> >I have a problem, I need to display a random result (one) from a
table
>> of
>> >> 25
>> >> >possibles.

>> >> >My query will give a random selection from a table by inserting;

>> >> >Int((upperbound - lowerbound + 1) * Rnd + lowerbound)

>> >> >Each time I run the query I get a random result. Great, except I need
>to
>> >> >display the results in a form and on the Web and of course it just
>keeps
>> >> >showing the same record!

>> >> >Database is small (25 records) How do I get the record to change when
>> the
>> >> >form is reloaded or the web page is refreshed etc. Not a novice but
>> >> >defiantly not even remotely an expert!

>> >> >M

 
 
 

Getting a from to show random results

Post by mett » Sat, 16 Dec 2000 01:55:29


Sorry but where do I put the extra bits "functionx()" etc

M


> This is kind of a guess...

> When you use rnd function,  and you do not give it a seed,  it will
generate
> random numbers just fine.

> but if you stop the execution of the program and restart it,  it will give
> you the same numbers in the same order.

> You can avoid this by planting a seed

> function x()
>     randomize timer
>     x = Int((25-1+1)*Rnd()+1)

> end sub

> since your web page is reloading each time,  it might be like restarting
> your application..

> here is a idea. Make a second web page and put two random query's in it.
> see if you get the same result that way..

> Hope this helps.

> Wayne


> >Hi and thanks for trying to help.

> >OK perhaps I should explain a little. Database has 25 records and I would
> >like to display 1 record at random.
> >The query contains:

> >Int((25-1+1)*Rnd()+1)

> >This displays one random record when I run the query. If I then display
> this
> >query in a form it works too however when I try to use this same query on
a
> >web page the same record keeps coming up? (Front Page 2000 + Access 97)

> >Thanks if you can help with this problem.

> >M



> >> Maybe I don't fully understand what you are trying to do.

> >> the randomize timer uses the timer to generate different random
numbers.

> >> Now in your query,  You will have to build a random where clause.

> >> ie

> >> let sql = "select * from mytable where indexfields = " +
> Int((upperbound -
> >> lowerbound + 1) * Rnd + lowerbound)


> >> >Thanks, but How do I do this in a simple table, query or whatever?

> >> >M

> >> >--

> >> >http://www.metta.co.uk  Worth a pre launch visit



> >> >> you need a

> >> >> randomize timer

> >> >> this sets a seed


> >> >> >I have a problem, I need to display a random result (one) from a
> table
> >> of
> >> >> 25
> >> >> >possibles.

> >> >> >My query will give a random selection from a table by inserting;

> >> >> >Int((upperbound - lowerbound + 1) * Rnd + lowerbound)

> >> >> >Each time I run the query I get a random result. Great, except I
need
> >to
> >> >> >display the results in a form and on the Web and of course it just
> >keeps
> >> >> >showing the same record!

> >> >> >Database is small (25 records) How do I get the record to change
when
> >> the
> >> >> >form is reloaded or the web page is refreshed etc. Not a novice but
> >> >> >defiantly not even remotely an expert!

> >> >> >M

 
 
 

Getting a from to show random results

Post by Wayne Michae » Sat, 16 Dec 2000 02:21:26


I do not know what you code looks like.

If you have this on the serverside as a Server Side script..  then just put
before your RND statement

randomize timer

Then when you call the RND it will be seeded...

With ASP you may need to include the randomize timer at each point that you
have script.

ie <%
    randomize timer
    code
    >%

other HTML

<%
randomize timer
code
%>

I am not sure of this.  If I saw your code my might be able to give you more
help.


>Sorry but where do I put the extra bits "functionx()" etc

>M



>> This is kind of a guess...

>> When you use rnd function,  and you do not give it a seed,  it will
>generate
>> random numbers just fine.

>> but if you stop the execution of the program and restart it,  it will
give
>> you the same numbers in the same order.

>> You can avoid this by planting a seed

>> function x()
>>     randomize timer
>>     x = Int((25-1+1)*Rnd()+1)

>> end sub

>> since your web page is reloading each time,  it might be like restarting
>> your application..

>> here is a idea. Make a second web page and put two random query's in it.
>> see if you get the same result that way..

>> Hope this helps.

>> Wayne


>> >Hi and thanks for trying to help.

>> >OK perhaps I should explain a little. Database has 25 records and I
would
>> >like to display 1 record at random.
>> >The query contains:

>> >Int((25-1+1)*Rnd()+1)

>> >This displays one random record when I run the query. If I then display
>> this
>> >query in a form it works too however when I try to use this same query
on
>a
>> >web page the same record keeps coming up? (Front Page 2000 + Access 97)

>> >Thanks if you can help with this problem.

>> >M



>> >> Maybe I don't fully understand what you are trying to do.

>> >> the randomize timer uses the timer to generate different random
>numbers.

>> >> Now in your query,  You will have to build a random where clause.

>> >> ie

>> >> let sql = "select * from mytable where indexfields = " +
>> Int((upperbound -
>> >> lowerbound + 1) * Rnd + lowerbound)


>> >> >Thanks, but How do I do this in a simple table, query or whatever?

>> >> >M

>> >> >--

>> >> >http://www.metta.co.uk  Worth a pre launch visit



>> >> >> you need a

>> >> >> randomize timer

>> >> >> this sets a seed


>> >> >> >I have a problem, I need to display a random result (one) from a
>> table
>> >> of
>> >> >> 25
>> >> >> >possibles.

>> >> >> >My query will give a random selection from a table by inserting;

>> >> >> >Int((upperbound - lowerbound + 1) * Rnd + lowerbound)

>> >> >> >Each time I run the query I get a random result. Great, except I
>need
>> >to
>> >> >> >display the results in a form and on the Web and of course it just
>> >keeps
>> >> >> >showing the same record!

>> >> >> >Database is small (25 records) How do I get the record to change
>when
>> >> the
>> >> >> >form is reloaded or the web page is refreshed etc. Not a novice
but
>> >> >> >defiantly not even remotely an expert!

>> >> >> >M

 
 
 

Getting a from to show random results

Post by mett » Sat, 16 Dec 2000 02:34:50


I am doing this in Access 97 and then running the query from a straight
forward "Insert
Database Results" function in fp2000. I am very new to writing "code" so
although the
Int((25-1+1)*Rnd()+1)
Works when I create it in the "query criteria", I do not know how to or even
where to write the function side of it?

Thanks again for you help.

M


> I do not know what you code looks like.

> If you have this on the serverside as a Server Side script..  then just
put
> before your RND statement

> randomize timer

> Then when you call the RND it will be seeded...

> With ASP you may need to include the randomize timer at each point that
you
> have script.

> ie <%
>     randomize timer
>     code
>     >%

> other HTML

> <%
> randomize timer
> code
> %>

> I am not sure of this.  If I saw your code my might be able to give you
more
> help.


> >Sorry but where do I put the extra bits "functionx()" etc

> >M



> >> This is kind of a guess...

> >> When you use rnd function,  and you do not give it a seed,  it will
> >generate
> >> random numbers just fine.

> >> but if you stop the execution of the program and restart it,  it will
> give
> >> you the same numbers in the same order.

> >> You can avoid this by planting a seed

> >> function x()
> >>     randomize timer
> >>     x = Int((25-1+1)*Rnd()+1)

> >> end sub

> >> since your web page is reloading each time,  it might be like
restarting
> >> your application..

> >> here is a idea. Make a second web page and put two random query's in
it.
> >> see if you get the same result that way..

> >> Hope this helps.

> >> Wayne


> >> >Hi and thanks for trying to help.

> >> >OK perhaps I should explain a little. Database has 25 records and I
> would
> >> >like to display 1 record at random.
> >> >The query contains:

> >> >Int((25-1+1)*Rnd()+1)

> >> >This displays one random record when I run the query. If I then
display
> >> this
> >> >query in a form it works too however when I try to use this same query
> on
> >a
> >> >web page the same record keeps coming up? (Front Page 2000 + Access
97)

> >> >Thanks if you can help with this problem.

> >> >M



> >> >> Maybe I don't fully understand what you are trying to do.

> >> >> the randomize timer uses the timer to generate different random
> >numbers.

> >> >> Now in your query,  You will have to build a random where clause.

> >> >> ie

> >> >> let sql = "select * from mytable where indexfields = " +
> >> Int((upperbound -
> >> >> lowerbound + 1) * Rnd + lowerbound)


> >> >> >Thanks, but How do I do this in a simple table, query or whatever?

> >> >> >M

> >> >> >--

> >> >> >http://www.metta.co.uk  Worth a pre launch visit



> >> >> >> you need a

> >> >> >> randomize timer

> >> >> >> this sets a seed


> >> >> >> >I have a problem, I need to display a random result (one) from a
> >> table
> >> >> of
> >> >> >> 25
> >> >> >> >possibles.

> >> >> >> >My query will give a random selection from a table by inserting;

> >> >> >> >Int((upperbound - lowerbound + 1) * Rnd + lowerbound)

> >> >> >> >Each time I run the query I get a random result. Great, except I
> >need
> >> >to
> >> >> >> >display the results in a form and on the Web and of course it
just
> >> >keeps
> >> >> >> >showing the same record!

> >> >> >> >Database is small (25 records) How do I get the record to change
> >when
> >> >> the
> >> >> >> >form is reloaded or the web page is refreshed etc. Not a novice
> but
> >> >> >> >defiantly not even remotely an expert!

> >> >> >> >M

 
 
 

Getting a from to show random results

Post by Wayne Michae » Sat, 16 Dec 2000 02:36:21


I am not familiar with access.  You might look under macro's VBA (Visual
basic for applications)..


>I am doing this in Access 97 and then running the query from a straight
>forward "Insert
>Database Results" function in fp2000. I am very new to writing "code" so
>although the
>Int((25-1+1)*Rnd()+1)
>Works when I create it in the "query criteria", I do not know how to or
even
>where to write the function side of it?

>Thanks again for you help.

>M



>> I do not know what you code looks like.

>> If you have this on the serverside as a Server Side script..  then just
>put
>> before your RND statement

>> randomize timer

>> Then when you call the RND it will be seeded...

>> With ASP you may need to include the randomize timer at each point that
>you
>> have script.

>> ie <%
>>     randomize timer
>>     code
>>     >%

>> other HTML

>> <%
>> randomize timer
>> code
>> %>

>> I am not sure of this.  If I saw your code my might be able to give you
>more
>> help.


>> >Sorry but where do I put the extra bits "functionx()" etc

>> >M



>> >> This is kind of a guess...

>> >> When you use rnd function,  and you do not give it a seed,  it will
>> >generate
>> >> random numbers just fine.

>> >> but if you stop the execution of the program and restart it,  it will
>> give
>> >> you the same numbers in the same order.

>> >> You can avoid this by planting a seed

>> >> function x()
>> >>     randomize timer
>> >>     x = Int((25-1+1)*Rnd()+1)

>> >> end sub

>> >> since your web page is reloading each time,  it might be like
>restarting
>> >> your application..

>> >> here is a idea. Make a second web page and put two random query's in
>it.
>> >> see if you get the same result that way..

>> >> Hope this helps.

>> >> Wayne


>> >> >Hi and thanks for trying to help.

>> >> >OK perhaps I should explain a little. Database has 25 records and I
>> would
>> >> >like to display 1 record at random.
>> >> >The query contains:

>> >> >Int((25-1+1)*Rnd()+1)

>> >> >This displays one random record when I run the query. If I then
>display
>> >> this
>> >> >query in a form it works too however when I try to use this same
query
>> on
>> >a
>> >> >web page the same record keeps coming up? (Front Page 2000 + Access
>97)

>> >> >Thanks if you can help with this problem.

>> >> >M



>> >> >> Maybe I don't fully understand what you are trying to do.

>> >> >> the randomize timer uses the timer to generate different random
>> >numbers.

>> >> >> Now in your query,  You will have to build a random where clause.

>> >> >> ie

>> >> >> let sql = "select * from mytable where indexfields = " +
>> >> Int((upperbound -
>> >> >> lowerbound + 1) * Rnd + lowerbound)


>> >> >> >Thanks, but How do I do this in a simple table, query or whatever?

>> >> >> >M

>> >> >> >--

>> >> >> >http://www.metta.co.uk  Worth a pre launch visit



>> >> >> >> you need a

>> >> >> >> randomize timer

>> >> >> >> this sets a seed


>> >> >> >> >I have a problem, I need to display a random result (one) from
a
>> >> table
>> >> >> of
>> >> >> >> 25
>> >> >> >> >possibles.

>> >> >> >> >My query will give a random selection from a table by
inserting;

>> >> >> >> >Int((upperbound - lowerbound + 1) * Rnd + lowerbound)

>> >> >> >> >Each time I run the query I get a random result. Great, except
I
>> >need
>> >> >to
>> >> >> >> >display the results in a form and on the Web and of course it
>just
>> >> >keeps
>> >> >> >> >showing the same record!

>> >> >> >> >Database is small (25 records) How do I get the record to
change
>> >when
>> >> >> the
>> >> >> >> >form is reloaded or the web page is refreshed etc. Not a novice
>> but
>> >> >> >> >defiantly not even remotely an expert!

>> >> >> >> >M

 
 
 

Getting a from to show random results

Post by mett » Sat, 16 Dec 2000 02:49:21


Thanks for trying,

M

--

http://www.metta.co.uk  Worth a pre launch visit


> I am not familiar with access.  You might look under macro's VBA (Visual
> basic for applications)..


> >I am doing this in Access 97 and then running the query from a straight
> >forward "Insert
> >Database Results" function in fp2000. I am very new to writing "code" so
> >although the
> >Int((25-1+1)*Rnd()+1)
> >Works when I create it in the "query criteria", I do not know how to or
> even
> >where to write the function side of it?

> >Thanks again for you help.

> >M



> >> I do not know what you code looks like.

> >> If you have this on the serverside as a Server Side script..  then just
> >put
> >> before your RND statement

> >> randomize timer

> >> Then when you call the RND it will be seeded...

> >> With ASP you may need to include the randomize timer at each point that
> >you
> >> have script.

> >> ie <%
> >>     randomize timer
> >>     code
> >>     >%

> >> other HTML

> >> <%
> >> randomize timer
> >> code
> >> %>

> >> I am not sure of this.  If I saw your code my might be able to give you
> >more
> >> help.


> >> >Sorry but where do I put the extra bits "functionx()" etc

> >> >M



> >> >> This is kind of a guess...

> >> >> When you use rnd function,  and you do not give it a seed,  it will
> >> >generate
> >> >> random numbers just fine.

> >> >> but if you stop the execution of the program and restart it,  it
will
> >> give
> >> >> you the same numbers in the same order.

> >> >> You can avoid this by planting a seed

> >> >> function x()
> >> >>     randomize timer
> >> >>     x = Int((25-1+1)*Rnd()+1)

> >> >> end sub

> >> >> since your web page is reloading each time,  it might be like
> >restarting
> >> >> your application..

> >> >> here is a idea. Make a second web page and put two random query's in
> >it.
> >> >> see if you get the same result that way..

> >> >> Hope this helps.

> >> >> Wayne


> >> >> >Hi and thanks for trying to help.

> >> >> >OK perhaps I should explain a little. Database has 25 records and I
> >> would
> >> >> >like to display 1 record at random.
> >> >> >The query contains:

> >> >> >Int((25-1+1)*Rnd()+1)

> >> >> >This displays one random record when I run the query. If I then
> >display
> >> >> this
> >> >> >query in a form it works too however when I try to use this same
> query
> >> on
> >> >a
> >> >> >web page the same record keeps coming up? (Front Page 2000 + Access
> >97)

> >> >> >Thanks if you can help with this problem.

> >> >> >M



> >> >> >> Maybe I don't fully understand what you are trying to do.

> >> >> >> the randomize timer uses the timer to generate different random
> >> >numbers.

> >> >> >> Now in your query,  You will have to build a random where clause.

> >> >> >> ie

> >> >> >> let sql = "select * from mytable where indexfields = " +
> >> >> Int((upperbound -
> >> >> >> lowerbound + 1) * Rnd + lowerbound)


> >> >> >> >Thanks, but How do I do this in a simple table, query or
whatever?

> >> >> >> >M

> >> >> >> >--

> >> >> >> >http://www.metta.co.uk  Worth a pre launch visit



> >> >> >> >> you need a

> >> >> >> >> randomize timer

> >> >> >> >> this sets a seed




- Show quoted text -

Quote:> >> >> >> >> >I have a problem, I need to display a random result (one)
from
> a
> >> >> table
> >> >> >> of
> >> >> >> >> 25
> >> >> >> >> >possibles.

> >> >> >> >> >My query will give a random selection from a table by
> inserting;

> >> >> >> >> >Int((upperbound - lowerbound + 1) * Rnd + lowerbound)

> >> >> >> >> >Each time I run the query I get a random result. Great,
except
> I
> >> >need
> >> >> >to
> >> >> >> >> >display the results in a form and on the Web and of course it
> >just
> >> >> >keeps
> >> >> >> >> >showing the same record!

> >> >> >> >> >Database is small (25 records) How do I get the record to
> change
> >> >when
> >> >> >> the
> >> >> >> >> >form is reloaded or the web page is refreshed etc. Not a
novice
> >> but
> >> >> >> >> >defiantly not even remotely an expert!

> >> >> >> >> >M

 
 
 

Getting a from to show random results

Post by mett » Sat, 16 Dec 2000 03:13:08


Is it possible to make an sql statement:

SELECT t_Runes.ID
FROM t_Runes
WHERE (((t_Runes.ID)=Int((25-1+1)*Rnd()+1)));

This gives me the random number from the ID of the table

This result is then used with another query which looks at the whole table
t_Runes where the ID of the random query matches the ID of the main t_Runes

But I need to make it change otherwise the same result keeps loading, how do
I use your:
function x()
    randomize timer
    x = Int((25-1+1)*Rnd()+1)

end sub

part of the query within an sql??? Sorry if this does not make sense.

Thanks
M


> Thanks for trying,

> M

> --

> http://www.metta.co.uk  Worth a pre launch visit



> > I am not familiar with access.  You might look under macro's VBA (Visual
> > basic for applications)..


> > >I am doing this in Access 97 and then running the query from a straight
> > >forward "Insert
> > >Database Results" function in fp2000. I am very new to writing "code"
so
> > >although the
> > >Int((25-1+1)*Rnd()+1)
> > >Works when I create it in the "query criteria", I do not know how to or
> > even
> > >where to write the function side of it?

> > >Thanks again for you help.

> > >M



> > >> I do not know what you code looks like.

> > >> If you have this on the serverside as a Server Side script..  then
just
> > >put
> > >> before your RND statement

> > >> randomize timer

> > >> Then when you call the RND it will be seeded...

> > >> With ASP you may need to include the randomize timer at each point
that
> > >you
> > >> have script.

> > >> ie <%
> > >>     randomize timer
> > >>     code
> > >>     >%

> > >> other HTML

> > >> <%
> > >> randomize timer
> > >> code
> > >> %>

> > >> I am not sure of this.  If I saw your code my might be able to give
you
> > >more
> > >> help.


> > >> >Sorry but where do I put the extra bits "functionx()" etc

> > >> >M



> > >> >> This is kind of a guess...

> > >> >> When you use rnd function,  and you do not give it a seed,  it
will
> > >> >generate
> > >> >> random numbers just fine.

> > >> >> but if you stop the execution of the program and restart it,  it
> will
> > >> give
> > >> >> you the same numbers in the same order.

> > >> >> You can avoid this by planting a seed

> > >> >> function x()
> > >> >>     randomize timer
> > >> >>     x = Int((25-1+1)*Rnd()+1)

> > >> >> end sub

> > >> >> since your web page is reloading each time,  it might be like
> > >restarting
> > >> >> your application..

> > >> >> here is a idea. Make a second web page and put two random query's
in
> > >it.
> > >> >> see if you get the same result that way..

> > >> >> Hope this helps.

> > >> >> Wayne


> > >> >> >Hi and thanks for trying to help.

> > >> >> >OK perhaps I should explain a little. Database has 25 records and
I
> > >> would
> > >> >> >like to display 1 record at random.
> > >> >> >The query contains:

> > >> >> >Int((25-1+1)*Rnd()+1)

> > >> >> >This displays one random record when I run the query. If I then
> > >display
> > >> >> this
> > >> >> >query in a form it works too however when I try to use this same
> > query
> > >> on
> > >> >a
> > >> >> >web page the same record keeps coming up? (Front Page 2000 +
Access
> > >97)

> > >> >> >Thanks if you can help with this problem.

> > >> >> >M



> > >> >> >> Maybe I don't fully understand what you are trying to do.

> > >> >> >> the randomize timer uses the timer to generate different random
> > >> >numbers.

> > >> >> >> Now in your query,  You will have to build a random where
clause.

> > >> >> >> ie

> > >> >> >> let sql = "select * from mytable where indexfields = " +
> > >> >> Int((upperbound -
> > >> >> >> lowerbound + 1) * Rnd + lowerbound)




- Show quoted text -

> > >> >> >> >Thanks, but How do I do this in a simple table, query or
> whatever?

> > >> >> >> >M

> > >> >> >> >--

> > >> >> >> >http://www.metta.co.uk  Worth a pre launch visit



> > >> >> >> >> you need a

> > >> >> >> >> randomize timer

> > >> >> >> >> this sets a seed



> > >> >> >> >> >I have a problem, I need to display a random result (one)
> from
> > a
> > >> >> table
> > >> >> >> of
> > >> >> >> >> 25
> > >> >> >> >> >possibles.

> > >> >> >> >> >My query will give a random selection from a table by
> > inserting;

> > >> >> >> >> >Int((upperbound - lowerbound + 1) * Rnd + lowerbound)

> > >> >> >> >> >Each time I run the query I get a random result. Great,
> except
> > I
> > >> >need
> > >> >> >to
> > >> >> >> >> >display the results in a form and on the Web and of course
it
> > >just
> > >> >> >keeps
> > >> >> >> >> >showing the same record!

> > >> >> >> >> >Database is small (25 records) How do I get the record to
> > change
> > >> >when
> > >> >> >> the
> > >> >> >> >> >form is reloaded or the web page is refreshed etc. Not a
> novice
> > >> but
> > >> >> >> >> >defiantly not even remotely an expert!

> > >> >> >> >> >M

 
 
 

Getting a from to show random results

Post by Wayne Michae » Sat, 16 Dec 2000 22:57:04


You might try a stored procedure.  I am not sure if they support that or
not.

What you will most likely have to do (at least the way I would know how) is
create a macro/vbscript that calls your query's.

if you do this,  you can use the randomize feature.

I know access supports VBA..

mett wrote in message <91b2ji$ib...@lyonesse.netcom.net.uk>...
>Is it possible to make an sql statement:

>SELECT t_Runes.ID
>FROM t_Runes
>WHERE (((t_Runes.ID)=Int((25-1+1)*Rnd()+1)));

>This gives me the random number from the ID of the table

>This result is then used with another query which looks at the whole table
>t_Runes where the ID of the random query matches the ID of the main t_Runes

>But I need to make it change otherwise the same result keeps loading, how
do
>I use your:
>function x()
>    randomize timer
>    x = Int((25-1+1)*Rnd()+1)

>end sub

>part of the query within an sql??? Sorry if this does not make sense.

>Thanks
>M

>"mett" <me...@netcomuk.co.uk> wrote in message
>news:91b170$i4c$1@lyonesse.netcom.net.uk...
>> Thanks for trying,

>> M

>> --

>> http://www.metta.co.uk  Worth a pre launch visit

>> "Wayne Michael" <wrmich...@yahoo.com> wrote in message
>> news:wC7_5.132$75.110886@news1.iquest.net...
>> > I am not familiar with access.  You might look under macro's VBA
(Visual
>> > basic for applications)..

>> > mett wrote in message <91b0bp$i0...@lyonesse.netcom.net.uk>...
>> > >I am doing this in Access 97 and then running the query from a
straight
>> > >forward "Insert
>> > >Database Results" function in fp2000. I am very new to writing "code"
>so
>> > >although the
>> > >Int((25-1+1)*Rnd()+1)
>> > >Works when I create it in the "query criteria", I do not know how to
or
>> > even
>> > >where to write the function side of it?

>> > >Thanks again for you help.

>> > >M

>> > >"Wayne Michael" <wrmich...@yahoo.com> wrote in message
>> > >news:vo7_5.130$75.110593@news1.iquest.net...
>> > >> I do not know what you code looks like.

>> > >> If you have this on the serverside as a Server Side script..  then
>just
>> > >put
>> > >> before your RND statement

>> > >> randomize timer

>> > >> Then when you call the RND it will be seeded...

>> > >> With ASP you may need to include the randomize timer at each point
>that
>> > >you
>> > >> have script.

>> > >> ie <%
>> > >>     randomize timer
>> > >>     code
>> > >>     >%

>> > >> other HTML

>> > >> <%
>> > >> randomize timer
>> > >> code
>> > >> %>

>> > >> I am not sure of this.  If I saw your code my might be able to give
>you
>> > >more
>> > >> help.

>> > >> mett wrote in message <91au20$hp...@lyonesse.netcom.net.uk>...
>> > >> >Sorry but where do I put the extra bits "functionx()" etc

>> > >> >M

>> > >> >"Wayne Michael" <wrmich...@yahoo.com> wrote in message
>> > >> >news:KO6_5.129$75.109978@news1.iquest.net...
>> > >> >> This is kind of a guess...

>> > >> >> When you use rnd function,  and you do not give it a seed,  it
>will
>> > >> >generate
>> > >> >> random numbers just fine.

>> > >> >> but if you stop the execution of the program and restart it,  it
>> will
>> > >> give
>> > >> >> you the same numbers in the same order.

>> > >> >> You can avoid this by planting a seed

>> > >> >> function x()
>> > >> >>     randomize timer
>> > >> >>     x = Int((25-1+1)*Rnd()+1)

>> > >> >> end sub

>> > >> >> since your web page is reloading each time,  it might be like
>> > >restarting
>> > >> >> your application..

>> > >> >> here is a idea. Make a second web page and put two random query's
>in
>> > >it.
>> > >> >> see if you get the same result that way..

>> > >> >> Hope this helps.

>> > >> >> Wayne

>> > >> >> mett wrote in message <91asvr$hj...@lyonesse.netcom.net.uk>...
>> > >> >> >Hi and thanks for trying to help.

>> > >> >> >OK perhaps I should explain a little. Database has 25 records
and
>I
>> > >> would
>> > >> >> >like to display 1 record at random.
>> > >> >> >The query contains:

>> > >> >> >Int((25-1+1)*Rnd()+1)

>> > >> >> >This displays one random record when I run the query. If I then
>> > >display
>> > >> >> this
>> > >> >> >query in a form it works too however when I try to use this same
>> > query
>> > >> on
>> > >> >a
>> > >> >> >web page the same record keeps coming up? (Front Page 2000 +
>Access
>> > >97)

>> > >> >> >Thanks if you can help with this problem.

>> > >> >> >M

>> > >> >> >"Wayne Michael" <wrmich...@yahoo.com> wrote in message
>> > >> >> >news:IQ5_5.117$75.108733@news1.iquest.net...
>> > >> >> >> Maybe I don't fully understand what you are trying to do.

>> > >> >> >> the randomize timer uses the timer to generate different
random
>> > >> >numbers.

>> > >> >> >> Now in your query,  You will have to build a random where
>clause.

>> > >> >> >> ie

>> > >> >> >> let sql = "select * from mytable where indexfields = " +
>> > >> >> Int((upperbound -
>> > >> >> >> lowerbound + 1) * Rnd + lowerbound)

>> > >> >> >> mett wrote in message
><91anvi$m9...@taliesin2.netcom.net.uk>...
>> > >> >> >> >Thanks, but How do I do this in a simple table, query or
>> whatever?

>> > >> >> >> >M

>> > >> >> >> >--

>> > >> >> >> >http://www.metta.co.uk  Worth a pre launch visit

>> > >> >> >> >"Wayne Michael" <wrmich...@yahoo.com> wrote in message
>> > >> >> >> >news:ck5_5.113$75.108245@news1.iquest.net...
>> > >> >> >> >> you need a

>> > >> >> >> >> randomize timer

>> > >> >> >> >> this sets a seed

>> > >> >> >> >> mett wrote in message
>> <91amqj$m5...@taliesin2.netcom.net.uk>...
>> > >> >> >> >> >I have a problem, I need to display a random result (one)
>> from
>> > a
>> > >> >> table
>> > >> >> >> of
>> > >> >> >> >> 25
>> > >> >> >> >> >possibles.

>> > >> >> >> >> >My query will give a random selection from a table by
>> > inserting;

>> > >> >> >> >> >Int((upperbound - lowerbound + 1) * Rnd + lowerbound)

>> > >> >> >> >> >Each time I run the query I get a random result. Great,
>> except
>> > I
>> > >> >need
>> > >> >> >to
>> > >> >> >> >> >display the results in a form and on the Web and of course
>it
>> > >just
>> > >> >> >keeps
>> > >> >> >> >> >showing the same record!

>> > >> >> >> >> >Database is small (25 records) How do I get the record to
>> > change
>> > >> >when
>> > >> >> >> the
>> > >> >> >> >> >form is reloaded or the web page is refreshed etc. Not a
>> novice
>> > >> but
>> > >> >> >> >> >defiantly not even remotely an expert!

>> > >> >> >> >> >M

 
 
 

1. getting a random result set

I was wondering if there's any way to get a random result set on any
given query.
Right now I'm returning about 4000 entries, but then I have to go
through those and randomly select 100.  It takes way longer than it need
to if I could just return a random 100 from the original 4000.  Any help
is greatly appreciated.

thanks,
Tom Warner

2. Unknown number of fields

3. Showing record x of y when dataset is filtered/showing SQL results

4. pgsql-server/ oc/src/sgml/Tag: oc/src/sgml/REL ...

5. SHOW GETS vs. SHOW GET problem

6. How to know table size in SQL Server?

7. getting random records

8. Getting a random number between to values?

9. Getting a random public key

10. Getting random numbers from a related table

11. Getting a Random number without using RAND()

12. rand() - getting a random number for each row returned OR the art of randomly sorting queries