Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...Congratulations for your great site. This site helped me more than university..."

Geography

Where in the world do Tek-Tips members come from?
mohecan84 (MIS)
18 Jul 12 7:45
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
oharab (Programmer)
18 Jul 12 8:38
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

Quote (David W. Fenton)

We could be confused in exactly the same way, but confusion might be like Nulls, and not comparable.

mohecan84 (MIS)
18 Jul 12 8:46
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
dhookom (Programmer)
18 Jul 12 13:25
I would try:

CODE --> vba

If DCount("*", "Employees", "UserName = '" & Me.txtUserName & "' AND Permissions In('Coaching Logger','Admininstrator')") = 0 Then 

Duane
Hook'D on Access
MS Access MVP

mohecan84 (MIS)
19 Jul 12 7:17
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
dhookom (Programmer)
19 Jul 12 9:56
I expect your data is not what you think it is. Create a query with SQL of:

CODE --> 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

mohecan84 (MIS)
19 Jul 12 10:51
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.
dhookom (Programmer)
19 Jul 12 12:18
Did you try the SQL? Did you correct my spelling of Admininstrator?

Duane
Hook'D on Access
MS Access MVP

mohecan84 (MIS)
20 Jul 12 10:50
Hi Dhookom,

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

CODE --> Then

 

thank you for your help

kind regards,
Murtadau Gabier

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close