R
ryguy7272
I trying to run a function, but can’t quite figure out how to call it. The
Access Bible says that you have to add a function call to the Control Source
of a control, but I’m not sure how to do that. I guess the example in the
book used a Form to call the function. Do I need to call the function from a
Form? Can I call the function from a Table? I am trying to populate a Table
with IDs from each person’s computer (I think it is called system ID). Below
is the function:
'******************** Code Start **************************
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If (lngX > 0) Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = vbNullString
End If
End Function
'******************** Code End **************************
Thanks so much!!
Ryan---
Access Bible says that you have to add a function call to the Control Source
of a control, but I’m not sure how to do that. I guess the example in the
book used a Form to call the function. Do I need to call the function from a
Form? Can I call the function from a Table? I am trying to populate a Table
with IDs from each person’s computer (I think it is called system ID). Below
is the function:
'******************** Code Start **************************
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If (lngX > 0) Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = vbNullString
End If
End Function
'******************** Code End **************************
Thanks so much!!
Ryan---