Here is my code. I am trying to INSERT INTO "Master_Tab le" field "Edited_By" the variable value of "Editor"
"Editor" is the User Name of the person logged onto that computer
Code
"Editor" is the User Name of the person logged onto that computer
Code
Code:
Option Compare Database
Option Explicit
Declare Function WNetGetUser Lib "mpr.dll" _
Alias "WNetGetUserA" (ByVal lpName As String, _
ByVal Editor As String, lpnLength As Long) As Long
Const NoError = 0
Sub GetUserName()
Const lpnLength As Integer = 255
Dim status As Integer
Dim lpName, Editor As String
Editor = Space$(lpnLength + 1)
status = WNetGetUser(lpName, Editor, lpnLength)
If status = NoError Then
Editor = Left$(Editor, InStr(Editor, Chr(0)) -1)
CurrentDb.Execute "INSERT INTO Master_Table " &_
"(Edited_By) " & _
"VALUES ('" & Editor & "');"
Else
MsgBox "Unable to get the name."
End
End If
End Sub
Comment