Combo Box Restriction - User name (1 Viewer)

basshead22

Registered User.
Local time
, 22:40
Joined
Dec 17, 2013
Messages
52
I have a combo box with a list of employees I want to restrict the user/employee to be able to only pick his name from the combo box? Is it possible?

Thank you in advance!
 

pbaldy

Wino Moderator
Staff member
Local time
, 22:40
Joined
Aug 30, 2003
Messages
36,127
In order to do that you'd have to know what it is (which is possible). If you know what it is, why not just default it into the combo and not make/let them select anything?
 

Mihail

Registered User.
Local time
Today, 08:40
Joined
Jan 22, 2011
Messages
2,373
And, in my understanding, the combo is not necessary at all.
 

Cronk

Registered User.
Local time
Today, 15:40
Joined
Jul 4, 2013
Messages
2,772
Why indeed have a combo box? Just have a text box with the user name.

If you must have a combo, set Locked to Yes and set its value to the user name when the form is opened, or alternatively set the combo's row source to the user name.
 

basshead22

Registered User.
Local time
, 22:40
Joined
Dec 17, 2013
Messages
52
You guys are right no need for a combo box just a text box with that users name defaulted based on the windows login. So how do I achieve this? I got the User log in name from my IT / Network guy and added to my employee's table under EmpUserLogin..

EmployeeId / EmpUserlogin / Last Name/ First Name/ Full Name

So now on my form how I do I get the textbox to display the name of the person logged in on the computer??

Thanks in advance!
 

Cronk

Registered User.
Local time
Today, 15:40
Joined
Jul 4, 2013
Messages
2,772
Another option

Me.txtUserLogonName=environ("Username")
 

Cronk

Registered User.
Local time
Today, 15:40
Joined
Jul 4, 2013
Messages
2,772
You're sharper than I am.
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 15:40
Joined
Jan 20, 2009
Messages
12,853
Use the function as I described here. It actually returns the username with a single line of code.

I really do wish our members would stop suggesting Environ("username").

The username environment variable (now there is a hint) is poor choice because it is easily tampered with.

Enter the following in a command window (AKA DOS box) and hit return.
Code:
Set username=AnythingYouLike
Now see what your environ based function returns.

Alternatively go to Advanced System Settings in System Properties and add username as a new environment variable.

The old API in Paul's link is unnecessarily clumsy.
 

David R

I know a few things...
Local time
Today, 00:40
Joined
Oct 23, 2001
Messages
2,633
Use the function as I described here. It actually returns the username with a single line of code.
I've never seen that before, but it's very elegant. :cool:

Added two references to it to Code Repository, in the hopes of remembering it for the future.
 

basshead22

Registered User.
Local time
, 22:40
Joined
Dec 17, 2013
Messages
52
Thank you all for your help! much appreciated! Happy New year!
 

Users who are viewing this thread

Top Bottom