Retrieve a Random Record?

Results 1 to 2 of 2

Thread: Retrieve a Random Record?

  1. #1
    Join Date
    Dec 1969

    Default Retrieve a Random Record?

    Any idea how I could go about retrieving a record at random from an Access database, so that each time a page loads it will have different information on it? Thanks<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Retrieve a Random Record?

    1) make sure the db has a primary key with the autonumber feature turned on.<BR>2) find the total # of records in the db.<BR>3) create a random number generator (genetates between 0 and 1. multiply the random number by the number of records in the db and round. call this number x.(be careful of zero ie. if x = zero then call the rnd# function again.)<BR>4) SELECT * FROM [Table] WHERE [auto number] = x<BR>there must be an easier way, but i bet this would work in a pinch.<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts