How to Call a random record from table in a form

KCBroncoFan

New member
Local time
Today, 16:46
Joined
Dec 17, 2009
Messages
3
Not sure if this is the right place to post this:

I have filled a table with questions and answers. I now would like to call the questions, randomly to "quiz" myself everyday.

Thank you for any help,

Scott
 
Hi;

Private Sub Form_Open(Cancel As Integer)
Randomize
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("YourTable", dbOpenDynaset)
With rs
If .EOF Then
Exit Sub
Else
.MoveLast
.AbsolutePosition = CLng(Rnd() * .RecordCount)
Me.YourTextBox = !YourFieldInTable
End If
.Close
End With
Set rs = Nothing
End Sub
 
Awesome,

Thanks much, this gives me a great base.:D
 

Users who are viewing this thread

Back
Top Bottom