Solved

VB environ

Posted on 2010-11-28
12
509 Views
Last Modified: 2012-05-10
Is is possible to replace the dropdown (Logged by) in the useform?

I was wondering if the computers username could be automatically displayed (Environ). It would just pick up the name of the PC as opposed to selecting a name in the dropdown.



userform.xls
0
Comment
Question by:Gazza83
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
  • +1
12 Comments
 
LVL 45

Assisted Solution

by:patrickab
patrickab earned 166 total points
ID: 34227013
Try:

TextBox1.Text = Environ("Username")
0
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 34227054
I would also suggest changing the .Locked property to true so that no one can change anything in that textbox....
0
 
LVL 37

Expert Comment

by:TommySzalapski
ID: 34227201
I think he wants Environ("ComputerName")
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 37

Expert Comment

by:TommySzalapski
ID: 34227325
For future reference, pull up a command prompt and type SET and it will give you a list of all the environment variables currently in the system. I use this a lot because I always forget what they are all called.
0
 

Author Comment

by:Gazza83
ID: 34227327
Yeap would like to lock the cell down, have been experimenting with altering the existing code but no joy yet.

0
 
LVL 37

Expert Comment

by:TommySzalapski
ID: 34227380
Lock what cell down? The textbox? Right click on it in the designer and hit properties and set Locked to true like Siddharth suggested. Also, if Environ doesn't work use VBA.Environ
To lock all the cells in the sheet just turn on protection. In the workbook_Open event do this
Private Sub Workbook_Open()
  Worksheets("Low Volume").Protect Password:="gary", UserInterfaceOnly:=True
End Sub

Open in new window

Then all the data will be protected from any changes except from within the code. Or you could protect the normal way (tools->protect sheet) and just unprotect and reprotect in the code.
0
 
LVL 37

Assisted Solution

by:TommySzalapski
TommySzalapski earned 167 total points
ID: 34227382
Here is a working example. Is this what you are after?
userform.xls
0
 
LVL 30

Accepted Solution

by:
SiddharthRout earned 167 total points
ID: 34228461
I think this is what you need ?

Sid
Sample.xls
0
 
LVL 45

Expert Comment

by:patrickab
ID: 34228963
Tommy,

>I think he wants Environ("ComputerName")

As this would always be the same on any individual computer there would be little point in accessing it.

A password on the other hand would serve a purpose - probably.

Patrick
0
 
LVL 37

Expert Comment

by:TommySzalapski
ID: 34229901
Yeah, I realized that later. He said " It would just pick up the name of the PC" but then I saw the labels in the userform and decided he actually did want Username.
0
 
LVL 45

Expert Comment

by:patrickab
ID: 34230321
It's always a problem interpreting the question... perhaps the asker will clarify matters.

Patrick
0
 
LVL 45

Expert Comment

by:patrickab
ID: 34235195
Gazza83 - Thanks for the points - Patrick
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question