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

Help refining code 1

Status
Not open for further replies.

PROXI

Vendor
Sep 16, 2003
136
US
This is the code that I have now. It just hides a button from anyone that is not on the admin list. Right now I am defining it in the code... But I know that there must be a new way to do it. Any help is appreciated.

Code:
Private Sub Mainhide()

Dim strResponse As String
Dim admin1 As String
Dim admin2 As String
Dim admin3 As String
Dim admin4 As String

admin1 = "u183376"
admin2 = "u177894"
admin3 = "u180329"
admin4 = "u148799"
strResponse = Environ("username")

If strResponse = admin1 Or _
   strResponse = admin2 Or _
   strResponse = admin3 Or _
   strResponse = admin4 Then
    
    Form_Main.Report.Visible = True

Else
    Form_Main.Report.Visible = False
        
End If

End Sub

Thanks,

PROXI
 
If you store the admin usernames in a table, then you could say something like:

Code:
Private Sub Mainhide()

If Not (IsNull(DLookup("YourAdminListField","YourAdminListTable", "YourAdminListField = '" & Environ("username") & "'")) Then
   Form_Main.Report.Visible = True
Else
   Form_Main.Report.Visible = False
End If

End Sub

Didn't test it, but something akin to that should work.

-Gary
 
While "interesting", it appears to not be properly implemented, as the generic process generally relies on the security GROUP, not the individual user. While the ubiquitous {F1 (aka Help from Ms. A, doesn't address the use of security in these terms, many of the third party tutorials do so, with explicit samples of the use of the "CurrentUser" to determine access rights by using the Group Membership.





MichaelRed
mlred@verizon.net

 
That right there just went far above my head. I am just hiding controls from people in an unsecured database.

Thanks,

PROXI
 
PROXI

Another apporach...

Code:
strAdmin = "u183376 u177894 u180329 u148799" 

If Instr(1, strAdmin, strResponse ) > 0 Then
...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top