R
RBear3
I have a "quiz" form that randomly pulls up questions from my table. It
works fine, and I don't mind that it repeats questions. This allows me to
sit and review for as long as I want.
The problem is, that I want to use criteria in a query to limit the
available questions. If I base this form on a query and limit the number of
questions, the code I am using is still setting the maximum number as the
number of records in my table.
In the past, I had a similar database (which I have lost) that would open
the form, set the selector to the last record available to the form, then
record that number as the max in my random setting. I think this portion of
the code was done in the event that fires when the form opens.
Can anyone help me change the following code so that I can do what I outline
above? I know I will have to move the "Dim NumOfRecords" line to my form's
open event, and I will have to add a line to jump to the last record. I'll
also have to move the "NumOfRecs=..." statement to my form's open event.
Private Sub Next_Question_Click()
Dim MyValue As Long
Dim NumOfRecs As Long
Answer.Visible = False
NumOfRecs = DCount("*", "Questions - Art")
MyValue = Int((NumOfRecs * Rnd) + 1)
DoCmd.GoToRecord , , acGoTo, MyValue
End Sub
works fine, and I don't mind that it repeats questions. This allows me to
sit and review for as long as I want.
The problem is, that I want to use criteria in a query to limit the
available questions. If I base this form on a query and limit the number of
questions, the code I am using is still setting the maximum number as the
number of records in my table.
In the past, I had a similar database (which I have lost) that would open
the form, set the selector to the last record available to the form, then
record that number as the max in my random setting. I think this portion of
the code was done in the event that fires when the form opens.
Can anyone help me change the following code so that I can do what I outline
above? I know I will have to move the "Dim NumOfRecords" line to my form's
open event, and I will have to add a line to jump to the last record. I'll
also have to move the "NumOfRecs=..." statement to my form's open event.
Private Sub Next_Question_Click()
Dim MyValue As Long
Dim NumOfRecs As Long
Answer.Visible = False
NumOfRecs = DCount("*", "Questions - Art")
MyValue = Int((NumOfRecs * Rnd) + 1)
DoCmd.GoToRecord , , acGoTo, MyValue
End Sub