looping....

A

accessdenied

I have an access application that runs 1 time and puts that in
query..

What I want to know is .. how do I get it to loop five times ?.. Thi
is a random drug testing database.. picking out 1 where i need to pic
out 5..

any ideas.. thanks

heres the code:



code:--------------------------------------------------------------------------------
Private Sub GetEmployees()
Dim intRnd, intRndHi, intRndLo As Integer
Dim strSQL, strCurrent As String
Dim lpBuff As String * 25 ' Set Up NTUSER NAME
Dim UserNameLong As Long ' Set Up NTUSER NAME
Dim NTUserName As String ' Set Up NTUSER NAME
UserNameLong = GetUserName(lpBuff, 25) ' Set Up NTUSER NAME
NTUserName = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1) ' Set Up NTUSE
NAME
NTUserName = "" & NTUserName ' Set Up NTUSER NAME
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![NextTestDate] = DateAdd("yyyy", 2, Me![Tested])
Me![UpdatedBy] = NTUserName ' Set Up NTUSER NAME
Me.Refresh
Command26_Click
End If

Exit_GetEmployees:
Exit Sub

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


End Sub
--------------------------------------------------------------------------------




thanks


I tried adding this line to the code.. but i get an error.. wron
number of arguements..


code:--------------------------------------------------------------------------------
Private Sub Command0_Click()
GetEmployees 5 'Test 5 DuPont Employees
Me.Requery
End Sub
 
H

Howard Brody

Dim i As Integer
i = 1
For i = 1 to 5
[insert code block here]
Next

Hope this helps!

Howard Brody
 

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