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!

Recordset Loop

Status
Not open for further replies.

Dimmer

MIS
Sep 18, 2001
8
CA
I'm running this code in the On_Load event form a form.

I want it to look at all records in the table, but it is only recognizing the last record in the table. I don't know what is wrong. Any help is greatly appreciated. Thanks

Dim Permission as Integer
Dim dbs As Database
Dim rdsDistMaster as recordset

Set dbs = CurrentDb
Set rdsDistMaster = db.Openrecordset("Select DistMaster from tblDistMaster")

rdsDistMaster.movefirst

Do Until rdsDistMaster.EOF = True
If fOSUserName = rdsDistMaster("DistMaster") Then
Permission = 1
Else
Permission = 0
End If
rdsDistMaster.movenext
Exit Do
Loop


 
Hi!

You need to move the Exit Do, like this:

Dim Permission as Integer
Dim dbs As Database
Dim rdsDistMaster as recordset

Set dbs = CurrentDb
Set rdsDistMaster = db.Openrecordset("Select DistMaster from tblDistMaster")

rdsDistMaster.movefirst

Do Until rdsDistMaster.EOF = True
If fOSUserName = rdsDistMaster("DistMaster") Then
Permission = 1
Exit Do
Else
Permission = 0
End If
rdsDistMaster.movenext
Loop

hth
Jeff Bridgham
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top