The creation and customization of database applications using Microsoft Access
“I can't get this to work” is too vague. What do you see that we don’t.
I usually recommend the code at the Access Web.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I can't get this to work hopefully there are answers already to this ?
The creation and customization of database applications using Microsoft Access
“I can't get this to work” is too vague. What do you see that we don’t.
I usually recommend the code at the Access Web.
AI answer
Environ("USERNAME") is the VBA function used to return the value of the Windows environment variable for the signed-in user.
Key points:
Environ(envstring) returns the string associated with an operating system environment variable."").Example in VBA:
MsgBox Environ("USERNAME")
If the goal is the Access database user instead of the Windows sign-in name, use CurrentUser instead:
MsgBox CurrentUser
CurrentUser returns the current database user account name. If workgroup security is not established, it returns the default user account, Admin.
If the goal is specifically the network or Windows logon name, Access documentation also provides an approach using a user-defined function that calls the GetUserNameA Windows API.