Get Logged On User Except if its Me

C

C. Hernandez

I have several queries where I only want it to pull data for the user. So I
use GetLoggedOnUser() in the criteria. There are a couple instances where I
want the criteria to pull the logged on user except if that user is me. I
tried a IIF statement, but that did not work.

This is what I used: IIf(GetLoggedOnUser()="me","*",GetLoggedOnUser())

Please help!!
 
R

Rick Brandt

C. Hernandez said:
I have several queries where I only want it to pull data for the
user. So I use GetLoggedOnUser() in the criteria. There are a couple
instances where I want the criteria to pull the logged on user except
if that user is me. I tried a IIF statement, but that did not work.

This is what I used: IIf(GetLoggedOnUser()="me","*",GetLoggedOnUser())

Please help!!

WHERE FieldName = GetLoggedOnUser()
OR GetLoggedOnUser()="me"
 
C

C. Hernandez

Reading your reply I realized I left out a crutial detail. I need the query
to give me all the records if the user is me and othwise restrict the records
to the logged on user.
 
R

Rick Brandt

C. Hernandez said:
Reading your reply I realized I left out a crutial detail. I need the
query to give me all the records if the user is me and othwise
restrict the records to the logged on user.

And that is what I gave you will do. The criteria is OR'd so if the second
statement is true (which it will be when you are the user) then that will be
satisfied for ALL records.
 
A

aaron.kempf

Select Suser_sname()

I mean come on guys-- this is built into Access Data Projects, just
about as easy as you can get

MDB shouldn't be used for anything-- what if someone disables macros?
 
Top