=Environ("username") (1 Viewer)

jrjr

A work in progress
Local time
Today, 01:35
Joined
Jul 23, 2004
Messages
291
I have noted a problem on 2 computers using this. There are around 30 or so computers on our network that work fine with this as a value. The majority of the users are at Access 2000 but some have Access XP. The offending machines have Access 2000

One day a persons computer crashed. DP imaged another persons machine and installed the image on the crashed machine as a solution. Since this the =Environ("username") returned #Name$ (not sure of the exact syntax on this). This same trouble surfaced on another machine recently. I unlocked the field so the users could enter their correct name but this can lead to errors and I would like to keep the username locked and read by code.

I checked the references on the offending machine and they were ok. Not sure what else there is to do to rectify this.

If anyone else has had a similar trouble and found the solution I would appreciate hearing about it.

Thanks a lot!!
-----------------------------
Edit:
I just checked the machine and corrected the syntax above. I also found that in a date search form where I have =now$() for a field, the same thing is displayed - #Name$ rather than the date.
 
Last edited:

ghudson

Registered User.
Local time
Today, 01:35
Joined
Jun 8, 2002
Messages
6,195
Even though you checked for missing references I would have to bet it is a reference problem if the Now() function is not working.

But, shouldn't it be =Now() not =Not$()

Will this work on the offending machines?

Code:
Msgbox Environ("UserName")
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 01:35
Joined
Feb 19, 2002
Messages
42,981
I don't use the Environ value to get the user name since in most places it is meaningless. It is better to get their network logon name. There are many functions posted here that show that code.
 

ghudson

Registered User.
Local time
Today, 01:35
Joined
Jun 8, 2002
Messages
6,195
Pat Hartman said:
I don't use the Environ value to get the user name since in most places it is meaningless. It is better to get their network logon name. There are many functions posted here that show that code.
Environ("UserName") does retrieve the users network [login] name.
 

jrjr

A work in progress
Local time
Today, 01:35
Joined
Jul 23, 2004
Messages
291
ghudson said:
Even though you checked for missing references I would have to bet it is a reference problem if the Now() function is not working.

But, shouldn't it be =Now() not =Not$()

Will this work on the offending machines?

Code:
Msgbox Environ("UserName")

My error.... yes, Now() does correct the problem with the date. Thanks for pointing that out to me! Sometimes we cant see the forest for the trees as the saying goes.

I will check the references again. Is there anything else that you can think of to look for??

I also need to correct a statement in my first post. One machine that has the trouble is using Access 2003 whereas I had said they were using 2000.
 
Last edited:

jrjr

A work in progress
Local time
Today, 01:35
Joined
Jul 23, 2004
Messages
291
I checked the references again and they still look fine. There are none that show up as missing.
 

ghudson

Registered User.
Local time
Today, 01:35
Joined
Jun 8, 2002
Messages
6,195
Where and/or how are you trying to use the =Environ("username") ?

You can not use =Environ("UserName") as the default value in a table field in Access 2003. You could in Access 97.
 

jrjr

A work in progress
Local time
Today, 01:35
Joined
Jul 23, 2004
Messages
291
I am using =Environ("UserName") as the default value of a text box on a form and the value returned is saved in the table.
 

ghudson

Registered User.
Local time
Today, 01:35
Joined
Jun 8, 2002
Messages
6,195
jrjr said:
I am using =Environ("UserName") as the default value of a text box on a form and the value returned is saved in the table.
That is ok, I stated...
You can not use =Environ("UserName") as the default value in a table field in Access 2003. You could in Access 97.
 

jrjr

A work in progress
Local time
Today, 01:35
Joined
Jul 23, 2004
Messages
291
I knew that there were other ways to achieve this and get the network login name, I was just wondering why this way would not work. I caved and used the solution provided on this page and it seems to have eliminated the trouble:

http://www.microsoft-accesssolutions.co.uk/network_user.htm

Thanks for the time and I would still be interested in finding out why it did not work......
 

Users who are viewing this thread

Top Bottom