Greg ... I had the same issue yesterday. I found this code online that will pull the user name used to log into Windows. I've applied it to my code and it works great.
JT
Option Compare Database
Option Explicit
'UserID variables
Public strSessionUserId As String
Public strSessionComputerId As String
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
'
Public Function fGetUserName()
'Returns a string representing the Windows Username
Dim lpName As String
Dim strTemp As String
'Set up buffer string
lpName = String$(255, 0)
Call GetUserName(lpName, 255)
If lpName = "" Then
strTemp = "NoUserName"
Else
strTemp = lpName
End If
fGetUserName = fStripNull(strTemp)
End Function
Public Function fGetComputerName()
'Returns a string representing the Windows Username
Dim lpName As String
Dim strTemp As String
'Set up buffer string
lpName = String$(255, 0)
Call GetComputerName(lpName, 255)
If lpName = "" Then
strTemp = "NoComputerName"
Else
strTemp = lpName
End If
fGetComputerName = fStripNull(strTemp)
End Function
Public Function fStripNull(StripText As String)
Dim strTemp As String
Dim intNum As Integer
Dim i As Integer
'Returns a string clear of trailing nulls (CHR(0)) and in the
'ASCII range 48-57, 65-90, 95 & 97-122 (0-9, A-Z, _, & a-z)
strTemp = ""
For i = 1 To Len(StripText)
intNum = Asc(Mid(StripText, i, 1))
Select Case intNum
Case 48 To 57, 65 To 90, 95, 97 To 122
strTemp = strTemp + Mid(StripText, i, 1)
Case Else
End Select
Next i
fStripNull = strTemp
End Function