Using User Level Security (ULS)

M

Mike

I currently running Access 2003 with Windows XP. My database is spilt. I have
set up various types of user groups and have assigned each user to a group.
The more restrictive group is able to add new data but can not edit, delete,
or add to the existing data.
My problem is when the more restricted user starts a new entry into the
form, clicks on a button to open a different form before the first form is
completed, they are locked out of finishing the first form when they return
to it. The "page" is not changed on the first form. It is not as if the user
has chosen to close the first form or hit "previous" or "next". I know I can
use a lesser restriction but only to allow the user to be able to edit the
data, but if did this, then there would be no need to use the ULS within
Access.
Thank You.
 
B

BruceM

You could disable the button to open the new form until the record is
"completed". The user is locked out of finishing the record because as soon
as they navigate to another record or otherwise leave the current form, the
record is saved. Once it is saved changes become edits or additions. You
will probably need some sort of validation, such as in the form's Before
Update event, to assure the record is completed.
One thing you could do is to have the user name (current user) entered
automatically into a field in the record, along with a time stamp. Then
allow that user to edit the record for an hour after it is created, or
something like that. Other than that sort of time extension by code you
will need to have data validation to prevent an incomplete record from being
saved.
 
M

Mike

How would I go about having the user name (current user) entered
automatically into a field in the record, along with a time stamp. Then
allow that user to edit the record for an hour after it is created?
 
B

BruceM

In the form's record source you would have a text field for the CurrentUser
and a Date/Time field for the time stamp. I will call these fields
RecordWriter and RecordTime.In the form's Current event you could have
something like:

If Me.NewRecord Then
Me.RecordWriter = CurrentUser
Me.RecordTime = Now
End If

This function is derived from the Microsoft Security FAQ, although somebody
who was helping me at the time may have altered it somewhat. I cannot take
much credit here, in any case. Place it in a standard code module.

Public Function UserGroup(ByVal GroupName As String) As Boolean

Dim usr As DAO.User
Dim grp As DAO.Group

Set usr = DBEngine.Workspaces(0).Users(CurrentUser)
For Each grp In usr.Groups
If grp.Name = GroupName Then
UserGroup = True
Exit For
End If
Next grp

End Function

In the form's Current event:

If UserGroup("Full Permissions") Then
Me.AllowEdits = True
Me.AllowDeletions = True
Else
If DateAdd("h",1,Me.RecordTime) <= Now And _
CurrentUser = Me.RecordWriter Then
Me.AllowEdits = True
Me.AllowDeletions = Ture
Else
Me.AllowEdits = False
Me.AllowDeletions = False
End If
End If

You could probably combine all of that, but I am not completely sure of the
syntax:

If UserGroup("Full Permissions") Or _
(DateAdd("h",1,Me.RecordTime) <= Now And _
CurrentUser = Me.RecordWriter) Then
Me.AllowEdits = True
Me.AllowDeletions = True
Else
Me.AllowEdits = False
Me.AllowDeletions = False
End If

This assumes there is a user group named Full Permissions.

DateAdd could be used for intervals of your choosing. Help has more
information.

BTW, you did not specify whether you are assigning permissions by user or by
group, but it is best to do it by group, even if the group consists of one
user. You can add or remove a user from a group much more easily than you
can assign permissions to each individual user.
 
²

²Ì´ä÷

Mike said:
I currently running Access 2003 with Windows XP. My database is spilt. I have
set up various types of user groups and have assigned each user to a group.
The more restrictive group is able to add new data but can not edit, delete,
or add to the existing data.
My problem is when the more restricted user starts a new entry into the
form, clicks on a button to open a different form before the first form is
completed, they are locked out of finishing the first form when they return
to it. The "page" is not changed on the first form. It is not as if the user
has chosen to close the first form or hit "previous" or "next". I know I can
use a lesser restriction but only to allow the user to be able to edit the
data, but if did this, then there would be no need to use the ULS within
Access.
Thank You.
 
L

lunwanting

Mike said:
I currently running Access 2003 with Windows XP. My database is spilt. I have
set up various types of user groups and have assigned each user to a group.
The more restrictive group is able to add new data but can not edit, delete,
or add to the existing data.
My problem is when the more restricted user starts a new entry into the
form, clicks on a button to open a different form before the first form is
completed, they are locked out of finishing the first form when they return
to it. The "page" is not changed on the first form. It is not as if the user
has chosen to close the first form or hit "previous" or "next". I know I can
use a lesser restriction but only to allow the user to be able to edit the
data, but if did this, then there would be no need to use the ULS within
Access.
Thank You.
 

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

Top