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
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