Script to hide tool bars on login

osullipa

Registered User.
Local time
Today, 18:17
Joined
Dec 7, 2004
Messages
31
I came across a script which should enable me to hide tool bars from users of the database. The code is as follows

Dim vUser As String
vUser = Environ$("UserName")

If vUser = YOURUSERNAME Then

Dim i As Integer
For i = 1 To CommandBars.Count
CommandBars(i).Enabled = False
Next i

Else
End If

End Sub
'END OF SUBROUTINE


The script works if I run it, but without entering a user name and password - all toolbars are hidden. I can't figure how get the user to enter the username and have the name passed to it. I have tried using the security section from the tools menu on the main database window without success. Can anyone please advise me on this?

Many thanks

Peter
 
Sounds to me like you want them hidden for everyone but you maybe?
If so, try this (substitute your own network log in name for YOURUSERNAME):


Dim vUser As String
vUser = Environ$("UserName")

If vUser <> YOURUSERNAME Then

Dim i As Integer
For i = 1 To CommandBars.Count
CommandBars(i).Enabled = False
Next i

Else
End If
 
Last edited:
Code:
Dim i As Integer 

If Environ$("UserName") <> "YourUserName" Then 

     For i = 1 To CommandBars.Count 
     CommandBars(i).Enabled = False 
     Next i 

Else

     For i = 1 To CommandBars.Count 
     CommandBars(i).Enabled = True 
     Next i 

End If
 
Thanks for this. My problem is now more simple than this!! How to I put the user name in to the system. Do I build a front end login form which has a control "username" on it , or can I do it from the tools menu in the main database window?


ghudson said:
Code:
Dim i As Integer 

If Environ$("UserName") <> "YourUserName" Then 

     For i = 1 To CommandBars.Count 
     CommandBars(i).Enabled = False 
     Next i 

Else

     For i = 1 To CommandBars.Count 
     CommandBars(i).Enabled = True 
     Next i 

End If
 
Thanks for this. My problem is now more simple than this!! How to I put the user name in to the system. Do I build a front end login form which has a control "username" on it , or can I do it from the tools menu in the main database window?

Regards

Peter



ghudson said:
Code:
Dim i As Integer 

If Environ$("UserName") <> "YourUserName" Then 

     For i = 1 To CommandBars.Count 
     CommandBars(i).Enabled = False 
     Next i 

Else

     For i = 1 To CommandBars.Count 
     CommandBars(i).Enabled = True 
     Next i 

End If
 
It depends on what you are doing now or what you want to do. Are your users logging into your db?

The Environ("UserName") will grab their network login name. You can compare that against a table listing all known users.

Are you just trying to hide the toolbars for everybody else but you?

For a quick test, assign this "as-is" to a command button and see what happens...
Code:
MsgBox Environ("UserName")
 

Users who are viewing this thread

Back
Top Bottom