retrieving username fails . .

TjS

Registered User.
Local time
Today, 19:18
Joined
Jul 18, 2007
Messages
126
Code:
Function fOSUserName() As String
On Error GoTo fOSUserName_Err

fOSUserName = Environ("Username") ' of vba.environ("Username")
Environ ("Username")

fOSUserName_Exit:
  Exit Function
  
fOSUserName_Err:
  MsgBox Error$
  Resume fOSUserName_Exit

End Function

Above mentioned code i use to retrieve the username from the network and use this username to specify information when retrieving information from a database.

What is my problem?
Well....on some network-clients this retrieving works perfectly the username is retrieved correctly and put into the table,
but on other network-clients (also tried logging in as myself on both mentioned network-clients) i get an error on the 4th line (
Code:
fOSUserName = Environ("Username")
on the word environ...

Please advise what could be the issue here?:confused:
 
It sounds like a missing reference?

also I recall there is a problem with Environ in some versions of access, as far as I can remember you need to call it explicitly, a good way is make a function for doing this and then call the function, you should be able to find information in this forum on it as it has occurred before, however if you have any further difficulty then please repost.

One of the "sticky" posts shows you how to search the forum.
 
Thanks

I have found a set of code searching this forum which accordingly to the notes, retrieves the username (and computername if applicable).
'
Thanks for all the help!
 
sharks....it doesn't work..

also this code doesn't work....anyone familiair with the problem that access causes problems when retreivnig the username? I tried four sets of different code to retreive it, none of it works in all workspaces...
 

Users who are viewing this thread

Back
Top Bottom