UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Query In Clause, Access 2016    
 
   
VBStudent
post Sep 10 2019, 07:15 PM
Post#1



Posts: 72
Joined: 17-April 16



Hello Everyone,

I need help with returning integer values to query-in clause. Please see the attached example. I'm trying to limit user's access to data to their specific departments. I'm trying to write a function that upon user's login, looks in 'TAccessList' to see what departments they have access to, and returns those values to 'QEmployees' under 'DeptID' criteria.


For exampe: UerID 2 (Emily) logs in to the database. She has access to department 1 and 4 (See TAccessList). I want to write a function that grabs DeptID 1 and 4 and passes them to 'QEmployees' query under the DeptID criteria as: In (1,4)


Would this be a possibility? So far, everything I have tried returns a string value that the query does not recognize. I have a large database with many other fields that I want to use in clause. Using joins is not an option for me at this time.

Thank you so much!

Attached File(s)
Attached File  Query_In_Clause.zip ( 29.19K )Number of downloads: 4
 
Go to the top of the page
 
RJD
post Sep 10 2019, 08:25 PM
Post#2


UtterAccess VIP
Posts: 10,095
Joined: 25-October 10
From: Gulf South USA


Hi: Try this as the Criteria ... In (SELECT DeptID FROM TAccessList WHERE USERID = 2)

I don't know where you get the login USERID, but you can reference that from wherever you keep it.

HTH
Joe

--------------------
"Each problem that I solved became a rule, which served afterwards to solve other problems."
"You just keep pushing. You just keep pushing. I made every mistake that could be made. But I just kept pushing."

Rene Descartes 1596-1650 (Mathematician and Philosopher)
Go to the top of the page
 
VBStudent
post Sep 11 2019, 03:28 AM
Post#3



Posts: 72
Joined: 17-April 16



Joe,

As always, many thanks. I'm getting the user ID when they log in using a function. So this is what I ended up doing: In (SELECT DeptID FROM TAccessList WHERE USERID = GetUserID()). thanks.gif
Go to the top of the page
 
RJD
post Sep 11 2019, 04:28 AM
Post#4


UtterAccess VIP
Posts: 10,095
Joined: 25-October 10
From: Gulf South USA


You are welcome. Glad that worked for you. thumbup.gif

Continued success ...

Regards,
Joe

--------------------
"Each problem that I solved became a rule, which served afterwards to solve other problems."
"You just keep pushing. You just keep pushing. I made every mistake that could be made. But I just kept pushing."

Rene Descartes 1596-1650 (Mathematician and Philosopher)
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    20th October 2019 - 01:34 AM