Get current Windows 98 Username

smercer

Registered User.
Local time
Today, 22:53
Joined
Jun 14, 2004
Messages
442
Hi all

I have a database which works great on Windows XP but fails because I am using code to get the user name and only works with Win XP that is:

Code:
Environ("UserName")

Could someone please tell me the code to use for windows 98?

Thanks a lot
scott
 
Run this on the Win98 box to see the available environ values. There should be one that works for all versions of Windows.

Code:
Public Function PrintEnvironValues()
    
    Dim i As Integer
    For i = 1 To 9999
        If Len(Trim(Environ(i))) = 0 Then
            Exit For
        Else
            Debug.Print i & " = " & Environ(i)
        End If
    Next i
    
End Function
 
CurrentUser returns the users name from the workgroup that the user is joined to. The default CurrentUser name is Admin. If you log into a database that is secured with a workgroup file *.mdw then CurrentUser will return the current user name that the user logged into the db as.

The original poster smercer is looking for the users network name.

For a quick test...

MsgBox CurrentUser

..will return "Admin" if the user's PC is joined to the default System.mdw workgroup file.
 
Thanks guys,

Will test when I get home.
 
CurrentUser returns the users name from the workgroup that the user is joined to. The default CurrentUser name is Admin. If you log into a database that is secured with a workgroup file *.mdw then CurrentUser will return the current user name that the user logged into the db as.

Is true
Code:
Public Function PrintEnvironValues()
    
    Dim i As Integer
    For i = 1 To 9999
        If Len(Trim(Environ(i))) = 0 Then
            Exit For
        Else
            Debug.Print i & " = " & Environ(i)
        End If
    Next i
    
End Function

and

If that fails then try one of these APIs...
None work in Windows 98. sorry ghudson.

Thanks for helping
 
Not sure what is going on for you or how you are using the code but I used to use all of those commands without fail with Windows 98 and Access 97.
 
ghudson said:
I used to use all of those commands without fail with Windows 98 and Access 97.

Thats what the problem is, you are using Access 97 and I am using access XP.

Thanks for your help.
 

Users who are viewing this thread

Back
Top Bottom