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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DLOOKUP Coding

Status
Not open for further replies.

mohecan84

MIS
Dec 7, 2011
13
ZA
Hi Guys,

I am having a bit of difficulty,

I am setting up an error check in my coding where if the User does not match 2 criteria they will not be allowed into the database. Can you please help me, I am pulling my hair out of my head over this. I will show what I currently have below, this allows for the first criteria ("Coaching Logger") but ignores the second criteria ("Administrator").

Code:
If DLookup("Permissions", "Employees", "UserName = ('" & Me.txtUserName.Value & "')") <> "Coaching Logger" Or DLookup("Permissions", "Employees", "UserName = ('" & Me.txtUserName.Value & "')") <> "Admininstrator" Then

MsgBox "You do not have permissions for this logger"

Your help is really appreciated.

kind regards,
Murtadau Gabier
 
Your logic is wrong.
If your requirement is that the permission is Neither "Coaching Logger" nor "Admininstrator" then you need to use AND.

hth

Ben

----------------------------------------------
Ben O'Hara
David W. Fenton said:
We could be confused in exactly the same way, but confusion might be like Nulls, and not comparable.
 
Hi Ben,

I have tried that, and it still only takes the "Coaching Logger" into consideration. I have even tried removing the portion of DLOOKUP script away before the "Administrator" portion so that it would be "Coaching Logger" And "Administrator" but none of this wants to work.

Kind regards,
Murtadau
 
Hi dhookom,

Thank you for the advice. I have now tried your bit of code and I get the same result. The code only looks at "Coaching Logger" and ignores whether the User could be an "Administrator".

Any thoughts on why this could be happening.

kind regards,
Murtadau Gabier
 
I expect your data is not what you think it is. Create a query with SQL of:
SQL:
SELECT *
FROM Employees
WHERE Permissions IN ("Coaching Logger","Admininstrator")
Do you see what you expect to see? Are all of the expected employees displayed?

Duane
Hook'D on Access
MS Access MVP
 
I am testing it with my own machine at the moment. If I change my permissions within the Employee table to "Coaching Logger" then it allows my access, but if I change myself from "Coaching Logger" to "Administrator" within the Employee table, it ignores that portion of the code and then gives me my MSGBox message.
 
Hi Dhookom,

With some help I have managed to get the problem sorted.

Code:

thank you for your help

kind regards,
Murtadau Gabier
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top