View Full Version : Random Select Help


Gootz11
07-28-2003, 09:15 AM
Hello,
I currently have a query that randomly selects 100 records from a table.
My SQL statement looks like this:
SELECT TOP 100 *
FROM [X1A Pick Slots]
ORDER BY Rnd(asc([slot]));

I'm trying to change my statement so that i can enter the number of records i want to select every time i run the query.
Please Help
Thanks in Advance
JG

dcx693
07-28-2003, 09:21 AM
Haven't tried this myself, but have you tried using a parameter query like this:
SELECT TOP [Enter the number of records to select: ] *
FROM [X1A Pick Slots]
ORDER BY Rnd(asc([slot]));

Gootz11
07-28-2003, 11:06 AM
Yeah, i tried the parameter statement but it didn't work. any other ideas???
Thanks

dcx693
07-28-2003, 11:16 AM
If that's not working, the only other thing I can think of is using a pop-up form to let the user input the number of records desired.

Pat Hartman
07-28-2003, 02:09 PM
You cannot supply that value as a parameter. The TOP x is part of the structure of the query and impacts how the query is optimized and so cannot be changed at runtime. The only solution is to build the SQL on the fly in code.