I am creating an Access report from one table. One of the fields is a numeric value. It is the file number that ranges from 1 to 4300. I want to show a random sample of 56 of these in the report. Please help me.
I would use the RND function to get records and add them to a table.<br>Then base your report on that table<br><br>--------------- Here is a simple one example that generates numbers ---------------<br>Public Sub RandomNums()<br> Dim db As Database, rst, rst2 As Recordset, SQL As String<br> Set db = CurrentDb<br> ' SQL string.<br> Set rst2 = db.OpenRecordset("RndNumbers"<br> For a = 1 To 25<br> SQL = "SELECT * FROM number1 WHERE numbers = " & Int((50 * Rnd) + 1) & ";"<br> Set rst = db.OpenRecordset(SQL)<br> rst2.AddNew<br> rst2!RndNumber = rst!Numbers<br> rst2.Update<br> Next<br> rst2.Close<br> rst.Close<br> db.Close<br> <br>End Sub<br>------------------------
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.