Amy35
04-02-2002, 10:16 AM
I used the code I found on this website (from Pat Hartman)to grab the current user name. When I put it in, I get the following error: The exp on open you entered as the event property setting produced the following error: "Only comments can appear after End Sub, End Function or End Property." It does look as though I am getting the user name, but the error stops you in your tracks.
Here's the code:
Option Compare Database
Option Explicit
Declare Function wu_WNetGetUser Lib "advapi32.dll" Alias "GetUserNameA" (ByVal sUser As String, nBuffer As Long) As Long
Function NetwareCurUser() As String
End Function
Dim sUser As String
Dim nBu As Long
Dim x As Variant
nBu = 8
sUser = Space(nBu)
x = wu_WNetGetUser(sUser, nBu)
sUser = Left(sUser, nBu - 1)
If IsNull(sUser) Then
MsgBox "Incorrect logon"
Else
NetwareCurUser = sUser
End If
End Function
Am I putting the code in the wrong place?
Thanks!
Amy
Here's the code:
Option Compare Database
Option Explicit
Declare Function wu_WNetGetUser Lib "advapi32.dll" Alias "GetUserNameA" (ByVal sUser As String, nBuffer As Long) As Long
Function NetwareCurUser() As String
End Function
Dim sUser As String
Dim nBu As Long
Dim x As Variant
nBu = 8
sUser = Space(nBu)
x = wu_WNetGetUser(sUser, nBu)
sUser = Left(sUser, nBu - 1)
If IsNull(sUser) Then
MsgBox "Incorrect logon"
Else
NetwareCurUser = sUser
End If
End Function
Am I putting the code in the wrong place?
Thanks!
Amy