I have a combo box on a form that I want to populate with user names.
If the person logged in has an admin role, they can choose any name in the company. If the user is not an admin, it will only show their own name.
What I’m looking for is something like:
If @Role='Admin' then
SELECT UserName FROM tblUsers
ELSE
SELECT UserName FROM tblUsers where UserID=@CurrentUser
I know how to pass in the parameters for @Role and @CurrentUser.
I think this query expresses the logic of what you’re trying to do.
However, I’m not sure how you would supply the parameters when that query is used as the row source for a combo box. You mentioned you have a method to do it. If that works here, you’re done. If not, I would suggest replacing the parameters with text boxes on the form.
You can hide the text boxes (set their Visible property to No), and their values will still be available to the query.