Environ("Username") Gives Error (1 Viewer)

ashleybyrdnc

Registered User.
Local time
Today, 05:19
Joined
Sep 27, 2006
Messages
17
I have been trying to use Environ("username") as criteria in a query to return the computer's login name. (Note I have a table with all the usersname) I can use it in a msg box in VB code to return the usersname, but not when I make it my criteria in a query,

I get the error Message
"undefined function 'Environ' in expression."

Please help me figure out what my problem is.
 

Attachments

  • username1.zip
    47.8 KB · Views: 480

mhartman

Dr. Data
Local time
Today, 05:19
Joined
Jun 5, 2006
Messages
442
Hello:

You want to use Environ(29) to return the user name. You would do this in your code.

Also, If you drop a text box on a form and set the controlsource to =Environ(29), this will return the username in that textbox as well.

Regards
Mark
 

Adeptus

What's this button do?
Local time
Today, 21:49
Joined
Aug 2, 2006
Messages
300
No, the numeric code won't help you at all. Plus it isn't the same across all machines.

The problem is Access's new "Sandbox" mode. It regards Environ() as an "unsafe expression", so will not let it run in queries.

The way around it is to create your own function in VBA, that calls Environ("Username"), then use that function in your query.

This was all covered on this forum recently (ie in the last few months), do a search.
edit: because I'm feeling helpful, try here: http://www.access-programmers.co.uk/forums/showthread.php?t=76173
 
Last edited:

cbeck

New member
Local time
Today, 08:19
Joined
Jan 28, 2008
Messages
1
Easier Solution!

This error is caused by the MACRO Security Settings within Access. To resolve the issue on the machine where it occurs...:
1) Open MS Access and from teh menu bar, select Tools --> Macro --> Security.
2) Check the "Low" checkbox on the Security Levels tab.
3) Close MS Access.
4) Open the database that had the error. It should now be removed.

;)
 

Users who are viewing this thread

Top Bottom