OK, you want 50 random records. You can do this one of two or three ways. I'll describe the one that I think is LEAST invasive of your existing structure.
Your table that lists your patients has some primary key. I will presume that it is not totally random itself, though that doesn't matter for this algorithm. Maybe it is an autonumbered record, maybe you count the number of records and add 1 before storing, maybe it has some other meaning. That does not matter. What matters is that it is a valid field for use as a primary key. That means no duplicates.
Create a new module (general, not class/form) or append to an existing module depending on what you have, a routine that does a randomize function and nothing else.
Public Function RNDMIZ() as Long
Randomize
RNDMIZ = 0
End Function
I used the name RNDMIZ but you can use anything you want.
Make a new, stand-alone table that gets reloaded each time you want to do this. Build the table. Build a separate Delete query to empty it before you run the macro I will suggest later in this post.
OK, here is where you have to get tricky. In this table, you need to have two fields.
tblRandomSel:
-- loPatientNumber (PK): Long, not an autonumber
-- sngRandom: Single precision floating
Now you need to populate the query by appending all the existing patient numbers to this new table. This would be easily done with an APPEND query that takes your patient number from the patient table and stuffs that into loPatientNumber. If you use the same field name in tblRandomSel for the patient number as you used in the patient table, the APPEND query will automatically make the assignment for you.
For the sngRandom field in this APPEND query, store the value returned from the Rnd() function. (It will show up as Expr1 for a field name in the query, but you don't really care about that.)
You are almost there... Now build one more query that joins the patient table with the tblRandomSel table. Sort the table by sngRandom. Now in the SELECT query, take the first 50 records.
SELECT FIRST 50 field-list FROM patient-table INNER JOIN tblRandomSel ON tblRandomSel.loPatientNumber = patient-table.patient-number ORDER BY sngRandom;
Build a macro that does a RunCode on the function you defined above. The option for the RunCode macro step will be the name of the function. The function name MUST BE PUBLIC, which is why I said to put it in a general module! It can't be public in a class module. Well, it can but it doesn't do any good.
Now put the DELETE query that erases the tblRandomSel table as the next step of the macro. Then put the APPEND query as the last step in that same macro.
Whenever you run the macro, you get a set of random numbers in the tblRandomSel table and the record count of that table is the same as your patient table. The JOIN lets you pick records based on their randomly generated number. You actually don't care the format of the number. All you care about is (1) they are random and (2) they can be sorted and (3) you can validly include a "FIRST 50" option on the SELECT statement.
Now you can use the query (which can includes everything from the patient table if you really needed it that way) to drive your reports or lists.