Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Look at all records

Status
Not open for further replies.

Dimmer

MIS
Sep 18, 2001
8
CA
I have these code statements that only look at the first record in a form: I need them to look at all of the records.

Dim tempuser as String
Docmd.OpenForm "subLock", acNormal,,acFormReadOnly, acHidden
Docmd.GoToRecord acDataForm, "subLock", acGoTo, 1
tempuser = Forms!subLock!Locker
Docmd.Close acForm, "subLock", acSaveNo

If fOSUserName = tempuser then
Me!AddPub.Visible = True
Else
Me.AddPub.Visible = False
End If

I just want this sub to look through all names that are in the form instead of just at the first, as it is doing now.
Any help would be greatly appreciated.
Thanks
Brian
 
Brian,

Have you ever used recordsets? You can open a recordset(table or query) and then loop through all the records and check every value if you want. Here is an example:

dim db as database
dim rst as recordset

set db = currentdb
set rst = db.openrecordset("table1")

//Loop through table1 under field 'User'
With rst
.MoveFirst
Do Until .EOF
Select Case .Fields("User").VALUE
Case "Tom"
// do something here
Case "Mary"
// do something here
End Select
.MoveNext
Loop
End With


I hope this helps you. Let me know.

Paul ::) Chaos, Disorder, my work here is done!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top