Include username and name from Windows into textbox

charly.csh

New member
Local time
Today, 09:22
Joined
May 7, 2020
Messages
9
Hi everyone,

I am making a form as report and also want to include the creator of the report based on the "windows user name and also the name" by default in the Windows system
The username is not an issue but I don't know how to add the "name by default" from the computer registration. Does somebody know the option?

Dim wshNetwork As Object 'New wshNetwork
Set wshNetwork = CreateObject("WScript.Network")
Me.Issuerusername = wshNetwork.username
'Me.IssuerName = wshNetwork. ???
Set wshNetwork = Nothing

'username: charlycsh
'Name: "Charles M. Burns"
 
What I have always done is maintain a strict table of any and all database users with all the required info … Just a thought..
 
It is a good idea, June7 also recommended to me the usage of Dlookup.

The idea of this was more like avoid that somebody else issue a report in the name of other person, at least the "issuer" will be recorded with the windows user but sometimes is name is something like "qasxd" and it does not give you more info
 
Yes, if you have potentially multiple users using the same database login with different pc's and different network logins, I can see what you mean.
 
This might help you

Code:
Public Sub pbListAllEnvironVars()
  
Dim i As Long

For i = 1 To 255
    If IsNull(Environ$(i)) = False Then
        Debug.Print i & "  -  " & Environ$(i)
    End If
Next i

End Sub
 
There are only about 40 Environ variables so I would suggest modifying the code suggested by @smig accordingly

Dim I As Integer
For I =1 To 40 ….

The code as written does not prevent blank rows appearing for i=41 to 255
 
Surely lan email address won't be an environment variable anyway, unless the local IT dept has done some major corporate IT ninja woofoo
 
I got 48 variables. Returns nothing after that. See the cross post link in post 3.
 
Since you can create environment user account variables, some may have more than others..?
 
Not sure what you mean about creating environment user account variables. I am just talking about intrinsic parameters for the Environ() function.
 
I don't know about creating environment user account variables. I am just talking about intrinsic parameters for the Environ() function
That code will loop through all environment variables. Although I am not sure whether they include system only, or system + user.
 
All I can say is after 48, returns nothing.

IsNull() test is not working. Prints anyway. Check for empty string instead.
 
There are only about 40 Environ variables so I would suggest modifying the code suggested by @smig accordingly

Dim I As Integer
For I =1 To 40 ….

The code as written does not prevent blank rows appearing for i=41 to 255
You are right.
Look carefully at my code
It wont print blank values
 
I ran your code and 255 lines output. I could see only 57 - 255 because the others rolled off screen.
 
It does print blanks which is why I commented on it
1590126137167.png

...and so on

However this version doesn't print any blank lines

Code:
Public Sub pbListAllEnvironVars()
 
Dim i As Integer

For i = 1 To 255
    If Nz(Environ(i), "") <> "" Then
        Debug.Print i & "  -  " & Environ(i)
    End If
Next i

End Sub
 

Users who are viewing this thread

Back
Top Bottom