in Access 2013 the CurrentUser() is "Admin". How can uou change it to a user that has logged on through a simple form that has confirmed the user and their password?
in Access 2013 the CurrentUser() is "Admin". How can uou change it to a user that has logged on through a simple form that has confirmed the user and their password?
That is the login form that I use, it does a good job at securing who gets in but the CurrentUser() is still set to the default "Admin" and I have been unsuccessful in my attempts to update theCurrentUser().
To expand on what Colin said, in older versions of Access (2003 and earlier) if you had the old ULS (User Level Security) implemented, then CurrentUser() would return the name of the user that had logged in through ULS. ULS is deprecated in newer versions so CurrentUser() won't do you any good.
Environ("UserName") will return the name of the user logged into the Windows environment, but that may or may not be the same user name they use to log into your application. You may need to roll your own function for this.
I was able to confirm the username and assign it to a string, but how can I move it to the default value in a text box. I tried by going into the properties of the form and putting =Environ("UserName") in the default value of the field. But it returned an error " #Name? "
or with a bit of code in the appropriate event, probably the form or report open or load event
me.username.defaultvalue=environ("Username")
Be aware that the "Username" retrieved using "Environ("Username")" can/could be changed in Windows by using the SET command in a DOS window.
(or you used to be able to change it)
Here is an option:
You can get the Windows logged in user name using the code at http://www.databasedev.co.uk/get_use...putername.html
It looks like you are/could be using 64 bit Access, so you should also read this https://msdn.microsoft.com/en-us/lib...ffice.14).aspx
(maybe also this -> https://social.msdn.microsoft.com/Fo...orum=accessdev)
It's my understanding from the Steve Bishop video that he has established usernames and passwords specific to the application. This is similar to Sean/Beetle's comment in post #5 related to Environ("username") and its usefulness to you.
Steve's subsequent videos show you how to take the concept further and manage what users have access to.
I'm Still running into a wall and it could be because I am not explaining what I am trying to do properly.
I have a subform and when it opens I want the default value of the control name "created by" to be the Environ("username").
What do I put in the property sheet - Default Value of the control named "created by' in order to return the users name who has logged into windows.
see post #8What do I put in the property sheet - Default Value
I did that and it still returns #Name? instead of the users name
this is not a difficult task, perhaps it is time you showed the code you are actually using. Also confirm the datatype for your 'created by' field.
Even though Environ returns a string, in order to apply it to the Default Value property of a control you still need to wrap it in additional string delimiters
Me!YourTextBox.DefaultValue = """" & Environ("Username") & """"