Setvalue with environ variables

ptenhet

New member
Local time
Today, 11:58
Joined
Jan 28, 2013
Messages
7
access 2007--I'm trying to use the setvalue to grab environ("username") to populate a form. Keep getting a "Function" error. Is this possible with the setvalue?
 
I use these:-

Code:
Option Compare Database
Option Explicit

Function fGetWinUserName() As String
    fGetWinUserName = VBA.Environ("UserName")
End Function      ' fGetWinUserName
 
Function fGetComputerName() As String
    fGetComputerName = VBA.Environ("COMPUTERNAME")
End Function      ' fGetComputerName
 
What you get using Environ() are the values of the environment variables. Note "variable". The default for Username variable is the username but the value is easily changed by the user.

Type this into a cmd window (not VBA) then see what Environ("username") returns afterwards.

Code:
Set username = anything

Better to get the actual information.
Code:
LoginName = CreateObject("wscript.network").UserName

MachineName = CreateObject("wscript.network").ComputerName
 

Users who are viewing this thread

Back
Top Bottom