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!

For JEBRY

Status
Not open for further replies.

Dimmer

MIS
Sep 18, 2001
8
CA
Thanks a lot for your suggestion, I think I've almost got it
Here is what I've got now:

Dim dbs as Database
Dim rdsLocker as recordset
Dim rdsDistMaster as recordset

Set dbs = current db
Set rdsLocker = ("Select Locker from tblLocking")
Set rdsDistMaster = ("Select DistMaster from tblDistMaster")

If rdsLocker.EOF and rdsLocker.BOF Then
rds.Locker.MoveNext
Do While Not rdsLocker.EOF
If fOSUSerName = rdsLocker("Locker") Then CheckUser = 1
Else CheckUser = 0
Exit Do
End If
Loop
End If

I'm getting an error message that says "End If without block If" and it highlights the End IF after Exit Do.
Any help would be appreciated.
Thanks

 
Dimmer,

Try taking out the end if that is highlighted. I beleive that the line:

If fOSUSerName = rdsLocker("Locker") Then CheckUser = 1

is one complete IF statement. You don't need an END IF line if you have IF an Then on the same line. Understand? I hope I made sense....

paul |-0 Chaos, Disorder, my work here is done!
 
The problem is that you have "CheckUser = 1" on the same line as the If condition. Your Else and End If become meaningless when you put the result of the condition right after the "Then". To correct, simply put the "CheckUser" on the next line, like this...

If fOSUSerName = rdsLocker("Locker") Then
CheckUser = 1
Else
CheckUser = 0
Exit Do
End If

Gary
 
Well said qwinn7!!

|-0

Chaos, Disorder, my work here is done!
 
Hi!

I agree with quinn7's structure. One more thing, I think that you need the Exit Do in the Then condition instead of the Else. That way you will exit the loop after finding a match. On the other hand, if you set CheckUser to 0 before the loop, then you could do away with the else part of the If statement completely. CheckUser will change to 1 if any match is found and stay 0 if no match is found.

hth
Jeff Bridgham
 
Hi!

I hate to confuse the issue, but I think there is a better way to do this. Try the following:

Set rdsLocker = ("Select Locker from tblLocking Where Locker = '" & fOSUserName & "'")

If rdsLocker.EOF And rdsLocker.BOF Then
CheckUser = 1
Else
CheckUser = 0
End If

That should get you the same results

hth
Jeff Bridgham
 
Even simpler...

If rdsLocker.BOF Then
CheckUser = 1
Else
CheckUser = 0
End If

Whenever I have opened a recordset, I found that checking for the EOF was essentially unnecessary; BOF only is sufficient. Please argue if you believe me wrong.

Gary
gwinn7

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top