Full Version: Preventing An Action Unless User Is In A Group
UtterAccess Discussion Forums > Microsoft® Access > Access Security
bryan fusilier
Hi all,
I'm kind of going crazy trying to figure out exactly how to code this. I have a form with a combo box on it. I've created some code that evaluates the value of the combo box and checks that value against a date. If that date is earlier than today's date, it pops up a message warning them that the cut off date is past and that they can't add a new item.

The rub is I have security groups setup (about 10 of them). One of those groups is "delete data user". What I really need to have happen is for only people in this group to NOT get this warning. So "delete data users" should be able to proceed as normal and everyone else should get the message and be prevented from choosing that selection.

I have this code which is evaluating the date and if it's early than today it's popping up the warning:

Private Sub cbolngSchdTA_Change()

If DLookup("[datScopeFreeze]", "tblLookupTA", _
"[lngIDLookupTA] = Form![lngSchdTA]") <= Now Then
MsgBox "Warning: Scope is frozen for this TA. You cannot add new items. Please see your manager.", vbCritical
Me.cbolngSchdTA.Undo

End If

End Sub


What I can't figure out how to do is to only allow people in the group "delete data user" to bypass this code and to be able to choose that value and continue on.

Any help would be greatly appreciated.
satish
You just need to include one more If statement before Msgbox and Undo...your Security group is it Access in-built or custom?
bryan fusilier
Hi,
I believe it's built in, but it was built a long time ago. We use the internal group features to create groups and then normally use the

isingroup function to turn things on and off. I'm just finding myself caught in a weird circle here where I can quite figure out the exact code that ignores everything if the user is in the
"delete data group" but enforces the code when they are in any of the other groups.

Thanks for your time!!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.