Greetings, I am seeking a working example of how to control the viewing of data by different user groups. For example, I have 4 organizations who each place data into a shared Access database. I do not want want organization 1 to be able to view organization 2/3/4 data. I would like to have a sleek, friendly interface form for my organizations to each enter 10 items (things like bio, status, description, or just items 1-10) but not be able to view each other's records. I need a working example so I can emulate best practices when I build my own.
A solution using VB.NET & SQL would be preferred, but MS Access is the next best thing.
Microsoft AccessVisual Basic.NETMicrosoft SQL Server 2008
Last Comment
GenericCog
8/22/2022 - Mon
Jeffrey Coachman
How good are you at VBA...?
Do you already have a login system in place that identifies the Users Group?
In a nutshell, the use logs on, and the "Group" is stored in a global variable
Then create a function to retrieve this value.
Then all forms and Reports have a recordsource that filters for only that group.
SELECT *
FROM YourTable
WHERE GroupID=GetGroupID()
Jeffrey Coachman
<I need a working example so I can emulate best practices when I build my own.>
Why not post what you have so far?
Instead of forcing us to create a working example from scratch?
...and "guessing" about all of the aspects of your current database...?
Jeff, Thanks for the quick response!! I'm looking at your example files right now. I'm familiar with VBA to the extent that I can write beginner level code. I'm comfortable with VB.NET.
I do not have anything for you to work from. I'm trying to meet the need of a future requirement. I was hoping I could see what the community already had in their bag before I try and reinvent the wheel. :-)
Jeffrey Coachman
OK, keep me posted
Alpesh Patel
Enter that UserGRoup in Table and Filter data based in Logged in user's usergroup
Jeff, I was able to completely understand this example and am in the process of building my own based on yours. Thanks!!!
Jeffrey Coachman
;-)
BTW if you are wondering why I use the function instead of the variable (to filter the form), ...it is because you can use the function anywhere (like in a query)
(You can use a function for query criteria directly, but not a code variable)
SELECT *
FROM YourTable
WHERE Group=GetGroup()
Also at some point the function can be modified to include validation, and.or other arguments.
;-)
Jeff
GenericCog
ASKER
AH!!!!! I was not sure about that... somewhere in the back of my mind I figured there would be a reason. Thank you so much for your help on this!!!
Do you already have a login system in place that identifies the Users Group?
In a nutshell, the use logs on, and the "Group" is stored in a global variable
Then create a function to retrieve this value.
Then all forms and Reports have a recordsource that filters for only that group.
SELECT *
FROM YourTable
WHERE GroupID=GetGroupID()