Question : Select value from table using fOSUserName

What is the best way to populate a bound textbox using fOSUserName. I already tried the following unsuccessfully:

Control Source was set to:
= DLookup("TeamMember", "tblSAC", "CorpId = '" & fOSUserName & "'")
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
Option Compare Database
 
'Dev Ashish
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 = ""
    End If
End Function
Open in New Window Select All

Answer : Select value from table using fOSUserName

Remember what I said about "No Record Found". You dont have to use No Record Found as default text but it doesnt find an entry

Random Solutions  
 
programming4us programming4us