Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Environment variable as criteria for Access query 1

Status
Not open for further replies.

DanD76

MIS
Jan 24, 2002
40
US
In an Access query, can the "username" environment variable be used as a criteria value?

I have an Access 2002 table where one of the fields contains people's network login user name. I'd like to create a query that only shows data records from the table that match the currently logged on user. For example, if I were logged in and ran the query it would only show the records where my name was in the user name field of the table. If someone else were logged in and ran the query, only records with their login name in the user name field would be displayed.

In batch/script files, you can use the %username% environment variable which contains the user's login name. Is there a simple way to do this in Access?
Thanks
 
Hi DanD76,

I can't test this but I think you can use Environ("username")

Enjoy,
Tony
 
Perfect. Does exactly what I wanted.
Thanks Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top