Home Forums Microsoft Access Microsoft Access Update Field to current logged in user ID with new record command button RE: Update Field to current logged in user ID with new record command button

  • I can't help you get the line of code to execute, since I cannot debug it myself.

    The reason CurrentUser() returns Admin is that CurrentUser() is returning the Access security user, which is by default, "Admin."

    Here is another option...

    Forget the Me.txtUserID = code in the cmdNew_click sub.

    Add the following function to a VB Module (not a form class module):

    Public Function GetWindowUser() as String

    GetWindowUser = Environ("USERNAME")

    End Function

    Then in the txtUserID Default property (instead of CurrentUser()), put:

    =GetWindowUser()

    That should work as an alternative.