random function

baksuz

Registered User.
Local time
Today, 14:24
Joined
Jan 25, 2005
Messages
12
:confused: Hello i am new in this word and i need help with random function.
I have a tabel with 1500 records and i want to get 300 records out of it randomly.

thank's for every help
 
thank's
i saw that thread before but i realy can't figure out how to do this

so it is easier to do it in VB than in query,you know i am complete zero in VB
there is now way for me to do it. :mad:
 
post a Db (in A97) and I'll have a look at it for you

Col
 
ok here it is but it is only in excel becouse of 100 k limit

i hope you can help me, good man
 

Attachments

hello
i found easy solution to this problem


SELECT TOP 300 *
FROM Tabela
ORDER BY Rnd([ID_Zapis])
 
hello
i found easy solution to this problem

SELECT TOP 300 *
FROM Tabela
ORDER BY Rnd([ID_Zapis])
Passing a field to the Rnd() function in a query is not so random because each time you start Access and run the query, the same 300 records will be returned.
 

Attachments

ja this is right i knew it can't be that easy, but if you start this function twice you get new 300 records. ja this is bad solution but it is :(
 
Take a look at Function Randomizer, written by Joe Foster and displayed in the Access Web at http://www.mvps.org/access/queries/qry0011.htm click here.

As an example of how you might use it to return random records from Northwind's Orders tables:

1) Copy/paste Function Randomizer to a new module:
Code:
Function Randomizer() As Integer
'by Joe Foster
'see [url]http://www.mvps.org/access/queries/qry0011.htm[/url]
Static AlreadyDone As Integer
   If AlreadyDone = False Then Randomize: AlreadyDone = True
   Randomizer = 0
End Function
2) Try pasting this SQL to a new query, then run the query:
Code:
SELECT TOP 25 Orders.OrderID, Orders.EmployeeID, Orders.OrderDate
FROM Orders
WHERE (((randomizer())=0))
ORDER BY Rnd(IsNull([Orders].[OrderID])*0+1);
It should return a different set of records each time it's run. Since you're
avoiding code, you'll need to modify the query SQL each time you want a different number of records.

Hope this provides 'food for thought'.

Bob
 
I tried this Joe Foster code but i get each time when i start same results.
am i doing something wrong or is this the same mistake like at the other one
 
I am sending you whole database and you can look it into. every time when you open database is the same result.
 

Attachments

Thanks for that. Any chance you could save and post it in A97?

Bob
 
This is becoming painful.

Is there any other kind soul who'll reduce Bakluz' database to A97
and repost it.

Thanks for the help.

Bob

p.s. I know, the ultimate solution is to reinstall A2000 then I wouldn't
have these glitches.
 
Bob,

We've been down this road before! Sometimes, Randomize doesn't really do
anything. Interesting thread though.

I tried to CVT the DB to A97, but Access says that it's missing a reference
and the new DB (which wasn't there) might not work. I'm sending it anyway.

Well, my work is done here.

Sorry, I couldn't help
Wayne
 
sorry i was asleep, i am sending you this databse in 97. i hope it will work now
 

Attachments

As best as I can detect, it's working and returning a different record set each time it's run. What is the mistake that you're referring to?

Bob
 
Couldn't get it to work in Access 97, 2000 and 2003. The same 300 records were repeated each time at Access startup.

These happened in both downloads.
 

Attachments

  • Screenshot Access 2000.jpg
    Screenshot Access 2000.jpg
    75.2 KB · Views: 100
  • Screenshot Access 2003.jpg
    Screenshot Access 2003.jpg
    75.6 KB · Views: 99

Users who are viewing this thread

Back
Top Bottom