Created a database that I want to be maintained and updated by the Department designated Admins. I have an user table that set specific individuals access to Admin and created admin form and functions to add data to tables and new users when needed. However, I only want the admins to see the command button on the form to access the Admin form menu. I have been unable to acheive this.
Hide Command button and form from group of users
Collapse
X
-
Assuming [Admin] is a Yes/No Data Type Field:
Assuming [Admin] is a Text Data Type Field:Code:Private Sub Form_Current() Me![Command13].Visible = DLookUp("[Admin]", "tbl_racifid") End Sub
Code:Private Sub Form_Current() Me![Command13].Visible = (DLookUp("[Admin]", "tbl_racifid") = "Yes") End SubComment
-
I changed the field type to yes/no and tweek the code a little to read:
Code:Private Sub Form_Open(Cancel As Integer) If DLookup("admin", "tbl_racfid", "[Racf_ID] = """ & Form_frm_login.Login_RacfID.Value & """") = True Then Me.btn_admin.Visible = True Else Me.btn_admin.Visible = False End IfComment
-
It's so good to see coders who can handle boolean evaluations properly. So many use the form :Assuming [Admin] is a Yes/No Data Type Field:
Assuming [Admin] is a Text Data Type Field:Code:Private Sub Form_Current() Me![Command13].Visible = DLookUp("[Admin]", "tbl_racifid") End Sub
Code:Private Sub Form_Current() Me![Command13].Visible = (DLookUp("[Admin]", "tbl_racifid") = "Yes") End Sub
instead of the more sensible :Code:If X = Y Then Z = True Else Z = False End If
The latter (your code) is so much more succinct and to the point, and shows an understanding of what you're dealing with.Code:Z = (X = Y)
Comment
Comment