This code is executed at open of a form in Access 97. An error appears on the win 98 machines but does not appear on the NT machines. The error is the one in the code because it is not finding the username. I have searched archived items and I was able to get the code working on win 95 by adding a statement to the autoexec.bat file. The statement was "set UserName=%username%". This did not work on WIN 98. I am looking for a simple solution to obtain the logged in user on a win 98 machine.
What should I add to this code or any other ideas?
Thanks
-------Code Begin--------
Private Sub Form_Load()
Dim EmployeeID As String
'
' Get employee ID from environment variable:
'
EmployeeID = Environ("USERNAME"
If EmployeeID = "" Then
EmployeeID = Environ("UserID"
End If
If EmployeeID = "" Then
MsgBox "Could not get UserID from system. Some functions may not be available", vbExclamation, "Warning!"
Else
Me![Employee ID] = EmployeeID
End If
DoCmd.Maximize
End Sub
--------Code End--------
What should I add to this code or any other ideas?
Thanks
-------Code Begin--------
Private Sub Form_Load()
Dim EmployeeID As String
'
' Get employee ID from environment variable:
'
EmployeeID = Environ("USERNAME"
If EmployeeID = "" Then
EmployeeID = Environ("UserID"
End If
If EmployeeID = "" Then
MsgBox "Could not get UserID from system. Some functions may not be available", vbExclamation, "Warning!"
Else
Me![Employee ID] = EmployeeID
End If
DoCmd.Maximize
End Sub
--------Code End--------