Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 2 / August 2007

Tip: Looking for answers? Try searching our database.

Calling random numbers from a set

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
tcb - 31 Aug 2007 14:35 GMT
I have a set of whole numbers (counting numbers) in tbl_WN.  There is
a field [Is_Prime] that indicates whether the number is prime.

I would like to create a set of prime numbers, then randomly call any
number from that set.  Based on what a user does on a form, a random
prime number may appear.

Can I create the set of prime numbers, have them stored in memory,
then call a random prime number from that set whenever I need one?

This code gives you an idea of how I am set up, loops through random
numbers in the set:

Dim intWN As Long

Dim db_Prime As Database
Dim rs_Prime As Recordset

Set db_Prime = CurrentDb
Set rs_Prime = db_Prime.OpenRecordset("Select WN from tbl_WN where
Is_Prime = -1 and WN between 1 and 10000")

rs_Prime.MoveFirst

Do Until rs_Prime.EOF

intWN = rs_Prime!wn

rs_Prime.MoveNext

Loop
Pieter Wijnen - 31 Aug 2007 19:10 GMT
check out Rnd & Randomize Functions

Pieter

>I have a set of whole numbers (counting numbers) in tbl_WN.  There is
> a field [Is_Prime] that indicates whether the number is prime.
[quoted text clipped - 27 lines]
>
> Loop
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.