Go to Random record

Psychobabble

Registered User.
Local time
Today, 23:11
Joined
Apr 26, 2003
Messages
13
I'm trying to create command button which will select and go to a random record in my form and my VB is woefully inadequate. Here's what I've got so far:

Dim rndRecord As Integer

rndRecord = Int((100 * Rnd) + 1)

DoCmd.GoToRecord , , acGoTo, rndRecord

This script will picks a random record between #0 and #100 no problems. Now what I'd like to is change that 100 to the number of records in the database (called "cases"). Anyone know how to do that?
 
try this
Code:
DoCmd.GoToRecord , , acGoTo, Int(Rnd() * Me.RecordsetClone.RecordCount) + 1
 
Great, that's all I needed!
 

Users who are viewing this thread

Back
Top Bottom