Username Problem

rnickels

Registered User.
Local time
Yesterday, 20:36
Joined
Dec 8, 2006
Messages
48
I have entered the following code to an onclick button. I am sure I have written it incorrectly (it's probably the line I highlighted below to do with username=Manager. By the way Manager is one of my usernames I have created.

Thanks for your help.

Rob

Private Sub Label218_Click()
If UserName = Manager Then
DoCmd.OpenReport "Tennis Teams", acNormal
Exit Sub
End If
MsgBox "You do not have permission to open this form!", vbOK, "Tennis Center Business Manager 2007"
End Sub
 
Unless Manager is a variable containing something else, put the word Manager in quotes.

If UserName = "Manager" Then




~Moniker
 
Not quite working

Thanks for the response but this does not work...I tried using CurrentUserName="Manager" but to no avail. Basically what I want to do is to check which User is currently logged on and from reference that username. ie. If the CuurentUser="a certain username" then open the form. If not, then a msg box appears

Moniker said:
Unless Manager is a variable containing something else, put the word Manager in quotes.

If UserName = "Manager" Then




~Moniker
 
Are you trying to see who is logged into Windows or your network, or do you have a separate login routine where you capture a user name? Both are easy fixes, although getting the Windows or Network login username requires an API call (which I'll provide if you need that).

~Moniker
 
Moniker -
Getting the Network login can be done:
Code:
strUser = Environ("username")
No API required.
 
Hmmm... I haven't tried it that way before. I'll have to see if that works once I'm back at work. Thanks for the tip. :)

~Moniker
 
I just learned about it myself a couple of months ago (on this forum). I wish I knew a long time ago as I was using the same long code as well.
 
Thanks again for responding.. I am trying to find out who is logged on to my database only.


Moniker said:
Are you trying to see who is logged into Windows or your network, or do you have a separate login routine where you capture a user name? Both are easy fixes, although getting the Windows or Network login username requires an API call (which I'll provide if you need that).

~Moniker
 
Your trying to find out who logged in to your database? This sounds like you have them login to the DB when the DB starts. If that's the case, either capture their user ID in a table at the point of login, or use a global variable for the login name, which would make it accessible anywhere.

~Moniker
 

Users who are viewing this thread

Back
Top Bottom