I am not clear as to where I add this to my query. Here is my complete SQL
view:
SELECT DISTINCTROW Children.Child_LName, Children.Child_FName,
Children.Child_MName, Children.Child_Admission_Date, Children.Child_DOB,
Enterprise_Organizations.Org_Name
FROM Enterprise_Organizations INNER JOIN Children ON
Enterprise_Organizations.Org_ID = Children.Home_ID
GROUP BY Children.Child_LName, Children.Child_FName, Children.Child_MName,
Children.Child_Admission_Date, Children.Child_DOB,
Enterprise_Organizations.Org_Name, Children.Child_ID, ([Child_id]) Mod 19,
Children.Campus_ID, Children.Child_ID, Children.Child_Status
HAVING (((([Child_id]) Mod 19)=0) AND ((Children.Campus_ID)=2) AND
((Children.Child_Status)="resident"))
ORDER BY Children.Child_LName, Children.Child_FName;
This query pulls me every 19th record from my list, but does not randomly
select them or change them when I re-run the query.
Well... no, it doesn't; there's no reason why it should. It also does
not use anything resembling my answer to your question, nor does it
reflect your original question (which had to do with retrieving a
single randomly selected record).
Try instead
SELECT TOP 5.26 PERCENT Children.Child_LName, Children.Child_FName,
Children.Child_MName, Children.Child_Admission_Date,
Children.Child_DOB,
Enterprise_Organizations.Org_Name
FROM Enterprise_Organizations INNER JOIN Children ON
Enterprise_Organizations.Org_ID = Children.Home_ID
GROUP BY Children.Child_LName, Children.Child_FName,
Children.Child_MName,
Children.Child_Admission_Date, Children.Child_DOB,
Enterprise_Organizations.Org_Name, Children.Child_ID, ([Child_id]) Mod
19,
Children.Campus_ID, Children.Child_ID, Children.Child_Status
HAVING (((([Child_id]) Mod 19)=0) AND ((Children.Campus_ID)=2) AND
((Children.Child_Status)="resident"))
ORDER BY Rnd([Child_ID]);
or - for more thorough randomization - create a new Module named
basRandom, with the following code:
Public Function RndNum(vIn As Variant) As Double
Static bRandomized As Boolean
If Not bRandomized Then ' Reset the random number
' generator, only the first time the function is called
bRandomized = True
Randomize
End If
RndNum = Rnd()
End Function
and use RndNum([Child_ID]) in the Order By clause.
John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps