Random Testing...

A

accessdenied

I have an app that randomly picks out 5 employees to get tested.. In
this program it picks out five and puts them back in the table to get
picked again..

I was wonder if there a way to instead of putting them back in.. once
they get picked.. take them off the list.. until the last employee has
been selected to test. .. once the last employee is selected.. it
starts over again..

...

I was also thinking.. is there a way .. the user can choose how many
employees to get randomly tested ?

I have some code here that just randomly picks out 5 employees.. I'm
having trouble getting them out of the list to choose from again .. and
put back to test..


Code:
--------------------

Private Sub GetEmployees()
Dim intRnd As Integer
Dim intRndHi As Integer
Dim intRndLo As Integer
Dim strSQL, strCurrent As String

Randomize

strCurrent = Date
Me.RecordSource = "SELECT COUNT ([Name]) AS NoName FROM Table1"
If Me![NoName] = 0 Then
MsgBox "Warning! No Records Selected!"
Exit Sub
Else
intRndLo = 1
intRndHi = Me![NoName]
'MsgBox "Press OK to Select Employee"
intRnd = Int((intRndHi - intRndLo + 1) * Rnd + intRndLo)
strSQL = "SELECT * FROM Table1 "
Me.RecordSource = strSQL
DoCmd.GoToRecord acDataForm, "frmRandom", acGoTo, intRnd
Me![Tested] = Format(Date, "Short Date")
Me.Refresh
End If
Exit_GetEmployees:
Exit Sub

intRnd = ""
intRndHi = ""
intRndLo = ""

'------------------------------------------------------------

End Sub
Private Sub Command0_Click()
Dim intCounter As Integer
For intCounter = 1 To 5
Call GetEmployees 'Test 5 DuPont Employees
Me.Requery
Next intCounter
End Sub
 
J

John Smith

Add a Boolean field to your employee table. When you pick the employee, update
the field to True. Before you start picking, count how many records are still
marked False, if less than five then update them all to False.

To vary the number tested, just add an InputBox to your click event and use the
input number instead of the hard-coded five.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top