View Full Version : record specific Security


Full_Williams
10-21-2003, 02:17 PM
Hi,

I searched the forum, but I didn't find anything on this. Is there a way to get record specific security with Access. I don't think there is, but wanted to know if anyone knew for sure.

Thanks,
Full Williams

Pat Hartman
10-22-2003, 01:26 PM
There is no "data" security within Access. The security relates only to objects and what the user is allowed to do with them. Any "data" related security will need to be custom built by you.

Full_Williams
10-23-2003, 05:21 AM
Thanks Pat,

So I'll have to use "CurrentUser" in my code?

If I want a Project Officer to only see data that he/she's the project officer for I would have something along the lines of this....

If CurrrentUser = rst0![ProjectOfficer] then
DoCmd.OpenForm
Else
msgbox "You do not have permissions to view this data"
end if

Obviously there will be more to the code, but I just want to make sure I'm on the right track and if it's possible to do.

Thanks,
Full Williams

Pat Hartman
10-23-2003, 12:12 PM
Yes, something along those lines but you will be referring to a control on your form rather than to a DAO.recordset field.

If CurrentUser() <> Me.txtProjectOfficer Then
...
Else
...
End If

Full_Williams
10-23-2003, 01:04 PM
Thanks Pat.

I'm going to have refer to a DAO.Recordset field because the user will be opening the form base on a different Field (GrantTitle) not the Project Officer. So I'll have to query out the record for the selected GrantTitle then check the Grant's ProjectOfficer against the CurrentUser to make sure they're the same.

I appreciate your help.

Full Williams

Pat Hartman
10-25-2003, 01:45 PM
Isn't ProjectOfficer a column in the recordset that the form is based on? If it is, you don't need a separate query. Just include it in the form's recordsource even if you are not showing it in a control.

Full_Williams
10-27-2003, 07:32 AM
Hi Pat,

Thanks for your response.

The ProjectOfficer is in a column on the form I'm opening(frmGrantInfo) and is already showing in a control. I don't want the form to open at all if the CurrentUser is not the Project officer for the frmGrantInfo.

Basically I have a number of ProjectOfficers that are responsible for different grants. To open the frmGrantInfo you select it by the grant name. I was thinking I would run a querydef when selecting the Grant Name pulling out the Grant Info for the selected Grant. I'll then check to see if the Current User is the project officer for the select grant. If the Current User is not the Project officer for the Grant then the user will get a message saying they don't have permissions to view the Grant information.

If you have any other suggests for a different approach please feel free.

Thanks,
Full Williams