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

DLookup with Multiple Criteria 1

Status
Not open for further replies.

meagain

MIS
Nov 27, 2001
112
CA
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
 
Simple fix:

Code:
Private Sub Form_Load()

If DLookup("Level", "USERS", "[USER ID] = '" & CurrentUser & "'") = 4 [blue]_
OR DLookup("Level", "USERS", "[USER ID] = '" & CurrentUser & "'") = 7[/blue] 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.
 
Thank you Andrzejek, it worked like a charm [smile]
 
I am glad. :)
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:

[pre]tbl_ShowStuff
Level ShowIt
1 True
2 True
3 True
4 False
5 True
6 True
7 False
8 True[/pre]

and use this table instead.


---- Andy

There is a great need for a sarcasm font.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top