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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filter by currentuser() except in one case?

Status
Not open for further replies.

MaddiMond

Technical User
Mar 28, 2005
76
US
Both my form and report are based on queries that are filtered by Username = CurrentUser(). I was just asked to have one person be able to look at the data from all the users. How can I incorporate that exception into the query?

Maddi
 
Try

(UserName = CurrentUser()) Or (UserName = SpecifiedUser)

Don't forget the single and double quotes as appropriate.

Hope this helps.
 
Maddi, I don't think what I said earlier will do what you want.

Presumably you query is run by some event such as a button click. So what I think you will need is something like:

Code:
If CurrentUser() = SpecifiedUser Then
  strSQL = "SELECT fieldlist FROM etc etc"
Else
  strSQL = "SELECT fieldlist FROM etc etc WHERE UserName '" = & CurrentUser() & "'"

Hope this is of more help.
 
(UserName = CurrentUser OR CurrentUser = 'SpecifiedUser')

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks,

I think I will have to use two query strings, but can I copy the SQL code from the query, or does VBA not understand that?

Maddi
 
Actually it worked to incorporate it into a query: just add:

AND ((USERNAME)=CurrentUser())) OR ... AND (([CurrentUser])='name'))

Thanks for your inputs.

Maddi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top