I was trying to grab the username (LANID) and place it in a text box on a form. I used Pat's 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
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
Works great but now I am getting an error on every single button I have (or create) (ie..add new ticket, find next, close, print etc.)Here's the error messgae I get:
"The expression on click you entered as event property setting produced the following error: constants , fixed length strings, arrays, user-defined types and declare statements not allowed as Public members of object modules"
I even deleted the buttons and used the wizard to re-create them. Same error occurs.
The LanID text box has the default setting of =fOSUserName() although the form (and error message) seems to run the same with or without that.
Anyone have any ideas on why the new code is causing the error message? the command buttons were working fine til I inserted the code to stamp the Username in the LANID text box. Thanks in advance for any help on this.
Amy
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
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
Works great but now I am getting an error on every single button I have (or create) (ie..add new ticket, find next, close, print etc.)Here's the error messgae I get:
"The expression on click you entered as event property setting produced the following error: constants , fixed length strings, arrays, user-defined types and declare statements not allowed as Public members of object modules"
I even deleted the buttons and used the wizard to re-create them. Same error occurs.
The LanID text box has the default setting of =fOSUserName() although the form (and error message) seems to run the same with or without that.
Anyone have any ideas on why the new code is causing the error message? the command buttons were working fine til I inserted the code to stamp the Username in the LANID text box. Thanks in advance for any help on this.
Amy