Solved

VB environ

Posted on 2010-11-28
12
471 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
  • 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
 
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

759 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now