Setting the value of a control

M

Miri

I have a database where we track issues. I have a form
and a subform where users add updates to the issues. I am
using the module below to get the Windows User Name to
autopopulate a field called UserName as users add
updates. It is working fine except I cannot set the value
of the field in the table to the windows user name. I
have tried using a SetValue macro to set the value when
the user focuses on that field but I keep getting an error
message that the subform is not found. Can anyone help.
Thanks.

Option Compare Database
Private Declare Function GetUserName Lib "advapi32.dll"
Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As
Long) As Long
Public Function GetWindowsUserName() As String
Dim s As String
s = Space(30) 'create a buffer
GetUserName s, 30 'call GetUserName
s = Left(s, (InStr(s, " ") - 2)) 'remove spaces (you can
also use Trim(s))
GetWindowsUserName = s
End Function
 
Top