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

Parameter Query: Return All Records if a Specific ID is entered

Status
Not open for further replies.

jmgibson

Technical User
Oct 1, 2002
81
0
0
US
Hi...I have a query that when executed, it asks the user for an ID (number). If the user enters a admin ID, the query will return ALL records, and if the user enters a non-admin ID, the query returns only those records tied to that ID entered. I'm not sure why this logic isn't working. Any thoughts?

=IIf([Forms]![Startup]![CurrentUser]=2541,like "*",[Forms]![Startup]![CurrentUser] )

Note: 2541 is a ADMIN ID.
 
I'd use this:
Code:
=[Forms]![Startup]![CurrentUser] OR [Forms]![Startup]![CurrentUser]=2541

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I'm guessing that this:
Code:
=IIf([Forms]![Startup]![CurrentUser]=2541,like "*",[Forms]![Startup]![CurrentUser] )
is being used as part of the where clause in the query but the two halves of the iif don't match. If your field is named ID then you're going to have:
Code:
ID like "*"
for the Admin and
Code:
ID42
if UserID 42 is logged in.

Furthermore, I think you should be generating two strings here so that you can insert them into the string for the SQL. Something like:
Code:
=Iif([Forms]![Startup]![CurrentUser]=2541, " like '*'", "=" & str([Forms]![Startup]![CurrentUser]) )

Written without warranty late on a Sunday evening

Geoff Franklin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top