R
requeth
Hello everyone,
I have the following code that is supposed to grab the Novell user ID,
the date, and save it into a table as a logfile.
Public Declare Function apiGetUserName Lib "advapi32.dll" Alias
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Function GetUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
Dim v_user As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If lngX <> 0 Then
GetUserName = Left$(strUserName, lngLen - 1)
Else
GetUserName = ""
End If
v_user = GetUserName
sqlInsertStatement = "Insert into UserLog([UserName],[LoginTime])
Values(" & v_user & ",'" & Date & "')"
DoCmd.SetWarnings False
DoCmd.RunSQL sqlInsertStatement
DoCmd.SetWarnings True
End Function
I set this as a module and then call it with a macro. When I run the
code a box pops up labeled "Enter Parameter Value" then the read only
Novell user ID, and a text box. If you ever information into the text
box and hit ok, that's saved as the user ID, if you do not, nothing is
saved except the date. I'm very rusty at VB, and to be honest did a
script kiddie hack job of a few scripts to get the above working (my
code keeled). Anyone see where I'm messing up?
Thanks!
I have the following code that is supposed to grab the Novell user ID,
the date, and save it into a table as a logfile.
Public Declare Function apiGetUserName Lib "advapi32.dll" Alias
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Function GetUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
Dim v_user As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If lngX <> 0 Then
GetUserName = Left$(strUserName, lngLen - 1)
Else
GetUserName = ""
End If
v_user = GetUserName
sqlInsertStatement = "Insert into UserLog([UserName],[LoginTime])
Values(" & v_user & ",'" & Date & "')"
DoCmd.SetWarnings False
DoCmd.RunSQL sqlInsertStatement
DoCmd.SetWarnings True
End Function
I set this as a module and then call it with a macro. When I run the
code a box pops up labeled "Enter Parameter Value" then the read only
Novell user ID, and a text box. If you ever information into the text
box and hit ok, that's saved as the user ID, if you do not, nothing is
saved except the date. I'm very rusty at VB, and to be honest did a
script kiddie hack job of a few scripts to get the above working (my
code keeled). Anyone see where I'm messing up?
Thanks!