2176,
Let's work through a few things and see if we can get to the root cause of the problem...
01. A complaint about the .Edit would seem to suggest a problem with the references to the database objects library. Probably that you do not have a reference to DAO, only ADO (the default).
You can check this out by highlighting a code module, clicking the "Design" button, then dropping down the "Tools" menu and selecting "References". Look down the list of ticked references (there are likely to be about 4 of them). Ensure there is one called "Microsoft DAO 3.6 Object Library". If there is not, scroll down the list until you see it and check the box opposite it. If the list of ticked references includes one called "Microsoft ActiveX Data Object Library..." UNcheck this one. Then click the OK button.
Getting the macro to run the query involves nothing more than adding a second comand to the same macro as the one calling the code funtion. The macro action is "OpenQuery", you then specify the query name. It would also be wise to display the query datasheet in read only mode.
If you want more detail on this part (or any other let me know).
Your 3rd point...
The field should be called "TmpRandNbr", not "Temp...". The field will by default be given a value of 0 (zero) when a new record is created (unless you changed the default to be something else). When the function is run it will loop through every record in the table and enter a random number between 0 and 1 into the TmpRandNbr field. The query, which gets run subsequent to the code function, orders the records in ascending order according to the value in TmpRandNbr and displays the top 15% of the list.
Hope this helps, but let me know either way. I'll be only to glad to help, whether it be more problem solving or guidance or info any any aspect.