Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Global Variable? 1

Status
Not open for further replies.

cranebill

IS-IT--Management
Jan 4, 2002
1,113
US
It has been a while since I have used access so I have a question. I want to pull the user name from windows. I have used the faq to due so... however now I would like it to be a global variable so that I dont have to load it on every form etc. As I recall years ago I had to do a splash screen to set the variable.

How do you set the variable and where do I put it, do I have to create another module etc?

The code used to get the variable is just as it is in the faq...

Dim strUser As String
strUser = fWin2KUserName

so now what? Any help appreciated.
 
You could put it in the same module.

Code:
Global WinUser As String

The above will declare your global variable.

Then All you have to do is set it...

Code:
WinUser = fWin2KUserName


The latter piece you can put in your own function that you run from an autoexec macro Or put the statement on load or on open event of a form that opens at startup (startup property or autoexec macro).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top