J
jez123456
I am using an Access ADP project which connects to SQL server using an SQL
login (GenLogin). My problem is obtaining a user’s individual domain login to
enter into an audit table.
Internally I can obtain the username using the following function
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
This is fine for certain parts of my application; however, it is in the
audit trail where I have problems.
I have a table (AuditLog) which has a column (UserName) with the Default
Value set to suser_sname()
This works ok, but of course will always save the SQL Server login
(GenLogin) and not the individual username.
How can I set the UserName Default Value to use a function that is in the
vba code?
Is there a sql server user defined function that will return this?
Thanks for your help
login (GenLogin). My problem is obtaining a user’s individual domain login to
enter into an audit table.
Internally I can obtain the username using the following function
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
This is fine for certain parts of my application; however, it is in the
audit trail where I have problems.
I have a table (AuditLog) which has a column (UserName) with the Default
Value set to suser_sname()
This works ok, but of course will always save the SQL Server login
(GenLogin) and not the individual username.
How can I set the UserName Default Value to use a function that is in the
vba code?
Is there a sql server user defined function that will return this?
Thanks for your help