I have a start-up form that grabs the user's WindowsID and puts it into a global variable. That is then used to track what they do around the database. Here's the code:
CODE
Global strUserName As String
Public Function GetUserPrivilegeLevel() As Variant
On Error GoTo Err_GetUserPrivilegeLevel
strUserName = Environ("Username")
etc..
Public Function GetUserPrivilegeLevel() As Variant
On Error GoTo Err_GetUserPrivilegeLevel
strUserName = Environ("Username")
etc..
I'm still learning how to do all this, and I probably should make it so that each time, say, a record is created, then the form where it's created imprints the value of strUserName into the "CreatedBy" field of my table.
But up to now I've been using a different system. In the table I have the default value for "CreatedBy" set to =Environ("Username") so that the info is grabbed without any problems. It works fine, but techincally isn't correct as I should be using strUserName.
If I change the field's default value to =strUserName() then it faults out with "Unknown Function in 'strUserName'...".
Can I make the table pick up this value, or MUST I do this at the form level?
(The reason I ask is that eventually, strUserName may be grabbed from a login form and may no longer be the pc's current Username).