Jumat, 28 Februari 2014

Bls: [belajar-access] Mau tanya mengenai Macro Access username

 


Untuk Nampilin UserName bisa juga dengan Environ("USERNAME")
misal taruh di event onload

LabelUser.Caption=Environ("USERNAME")


Salam,
Nyong


Pada Jumat, 28 Februari 2014 11:49, aksan kurdin <aksan.kurdin@gmail.com> menulis:
 
sub akan mengerjakan rutin, function adalah sub yang mengembalikan hasil.

sub printMe(str as string)
msgbox str
end sub

di jadikan function:

function printMe(str as string) as string
printMe = str
end function

jadikan recordsource dari textbox di form anda menjadi:
=printMe()

aksan kurdin

' Makes sure all variables are dimensioned in each subroutine.

' 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_Name2()

' 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 = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)

' Display the User Name
MsgBox UserName

End Sub

On 2/28/2014 9:07 AM, novendra ahmad wrote:
> ' Makes sure all variables are dimensioned in each subroutine.
>
>
> ' 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_Name2()
>
> ' 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 = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)
>
> ' Display the User Name
> MsgBox UserName
>
> End Sub



__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (5)
SPAM IS PROHIBITED
.

__,_._,___

Tidak ada komentar:

Posting Komentar