×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • 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!

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

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

DLookup with Multiple Criteria

DLookup with Multiple Criteria

DLookup with Multiple Criteria

(OP)
Hi,

We have a button on a form that we want only certain user levels to see. Users are listed in a table which identifies their level. The majority of the user levels are allowed to see the button, however levels 4 and 7 should not. We're able to accomplish hiding the button from level 4 users, but are unsure how to also hide the button from user level 7.

What do we need to add to the following, so that the button is also hidden from users at level 7?

Private Sub Form_Load()
If DLookup("Level", "USERS", "[USER ID] = '" & CurrentUser & "'") = 4 Then
Me.EVT_button.Visible = False
Else
Me.EVT_button.Visible = True
End If
End Sub


Thank you so much for your assistance with this.
L

RE: DLookup with Multiple Criteria

Simple fix:

CODE

Private Sub Form_Load()

If DLookup("Level", "USERS", "[USER ID] = '" & CurrentUser & "'") = 4 _
OR DLookup("Level", "USERS", "[USER ID] = '" & CurrentUser & "'") = 7 Then
    Me.EVT_button.Visible = False
Else
    Me.EVT_button.Visible = True
End If

End Sub 

Better fix - do NOT hard-code the values 4 and 7, have this information in a table and refer to it from there.


---- Andy

There is a great need for a sarcasm font.

RE: DLookup with Multiple Criteria

(OP)
Thank you Andrzejek, it worked like a charm smile

RE: DLookup with Multiple Criteria

I am glad. smile
But eventually you will have another Level that you will need to deal with, and you will have to add another line of code. Bad Idea.
That's why I would have another table:

tbl_ShowStuff
Level   ShowIt
1       True
2       True
3       True
4       False
5       True
6       True
7       False
8       True 

and use this table instead.


---- Andy

There is a great need for a sarcasm font.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

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! Already a Member? Login

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