Filtering records using a function

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello

I have a query that filters on StaffID based on the values returned by the
function getStaffList.

What i need to happen is that if the user is able to see ids 1, 2,5 then the
where cluase of the query become "Where staffID = 1 OR 2 OR 5"

the string "1 or 2 or 5' is returned by the function however its not working
because (i assume), the query is treating the full thing as a string.

is there any way to accomplish this? its a secured db so i cant just change
the query definition in code.

thanks.
 
Hello

I have a query that filters on StaffID based on the values returned by the
function getStaffList.

What i need to happen is that if the user is able to see ids 1, 2,5 then the
where cluase of the query become "Where staffID = 1 OR 2 OR 5"

the string "1 or 2 or 5' is returned by the function however its not working
because (i assume), the query is treating the full thing as a string.

is there any way to accomplish this? its a secured db so i cant just change
the query definition in code.

thanks.

Build the SQL in code, is the only easy way.

You could (at a heavy price in inefficiency) have your function return
a string like

^1^2^5^

and use a criterion

WHERE InStr(getStaffList([arguments]),"^" & StaffID & "^") > 0

John W. Vinson[MVP]
 
Thank you for that response.

I can't build the sql statment in code, because of user level security and
the users have NO permissions on the tables.

Your other method is the same as a co-worker had mentioned. It works great
(albeit with a performance issue)! Now all i need to do is code for circular
references created in that string.

Thanks again!

John Vinson said:
Hello

I have a query that filters on StaffID based on the values returned by the
function getStaffList.

What i need to happen is that if the user is able to see ids 1, 2,5 then the
where cluase of the query become "Where staffID = 1 OR 2 OR 5"

the string "1 or 2 or 5' is returned by the function however its not working
because (i assume), the query is treating the full thing as a string.

is there any way to accomplish this? its a secured db so i cant just change
the query definition in code.

thanks.

Build the SQL in code, is the only easy way.

You could (at a heavy price in inefficiency) have your function return
a string like

^1^2^5^

and use a criterion

WHERE InStr(getStaffList([arguments]),"^" & StaffID & "^") > 0

John W. Vinson[MVP]
 
Hi,


Make an inner join with a temporary table, one field, as many record as
values (no dup).


tempTable ' table name
f1 'field name
1
2
5 'values




SELECT a.*
FROM a INNER JOIN tempTable ON a.fieldName = tempTable.f1



will do. Since the tempTable is a table, you can have your user add and
remove data from it, without security problem, isn't it?



Hoping it may help,
Vanderghast, Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top