B
beavetoots
I've created macros before that I use to run code. When I try to run this
code, it gives me the following: Microsoft Access can't find the name
<lpbuffer> you enetered in the expression. Yet, if I open the module then
hit run, it runs fine. What the heck am I doing wrong?
This is the code:
Option Compare Database
Option Explicit
' Access the GetUserNameA function in advapi32.dll and
' call the function GetUserName.
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _
(ByVal lpBuffer As String, nSize As Long) As Long
' Main routine to Dimension variables, retrieve user name
' and display answer.
Sub Get_User_Name()
' Dimension variables
Dim lpBuff As String * 25
Dim ret As Long, UserName As String
' Get the user name minus any trailing spaces found in the name.
ret = GetUserName(lpBuff, 25)
UserName = Right(Left(lpBuff, InStr(lpBuff, Chr(0)) - 1), 5)
' Display the User Name
MsgBox UserName
End Sub
code, it gives me the following: Microsoft Access can't find the name
<lpbuffer> you enetered in the expression. Yet, if I open the module then
hit run, it runs fine. What the heck am I doing wrong?
This is the code:
Option Compare Database
Option Explicit
' Access the GetUserNameA function in advapi32.dll and
' call the function GetUserName.
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _
(ByVal lpBuffer As String, nSize As Long) As Long
' Main routine to Dimension variables, retrieve user name
' and display answer.
Sub Get_User_Name()
' Dimension variables
Dim lpBuff As String * 25
Dim ret As Long, UserName As String
' Get the user name minus any trailing spaces found in the name.
ret = GetUserName(lpBuff, 25)
UserName = Right(Left(lpBuff, InStr(lpBuff, Chr(0)) - 1), 5)
' Display the User Name
MsgBox UserName
End Sub