Hiding button on a form

ekta

Registered User.
Local time
Today, 16:46
Joined
Sep 6, 2002
Messages
160
Hi:

I have the followign code on the open event of my form. If the Userlevel is user then I want to hide a button on my form and if not I want to display it. When I run the code it displays the button even if Userlevel is user. Don't know what I am doing wrong?

Private Sub Form_Open(Cancel As Integer)

If DLookup("[USERLEVEL]", "N_tblLocalUser", "[USERLEVEL] = 'user'") = "user" Then
Me!Command0.Visible = False
Else
Me!Command0.Visible = True
End If
End Sub

Thanx
Ekta
 
Put the code in the Form_Load event and not the Form_Open.

Still though, this line confuses me:

If DLookup("[USERLEVEL]", "N_tblLocalUser", "[USERLEVEL] = 'user'") = "user"

Wouldn't looking up a field specifically where it is "user" equal "user" anyway?
 
Wouldn't you need to set it up like this?

If DLookup("[USERLEVEL]", "N_tblLocalUser", "UserID='" & CurrentUser() & "'") = "user"
 
That's what I was thinking - just a little late in the day to award my ramblings some clarity! :cool:
 

Users who are viewing this thread

Back
Top Bottom