Editing Restriction on Form - How to help?

Ode

Registered User.
Local time
Today, 15:54
Joined
Apr 18, 2005
Messages
10
Hi all,

I'm trying to restrict alterations to an existing record according to user.
In the end what i'm trying to accomplish is:

Only the user that entered a new record is allowed to make modifications, at a later time (updating with new and available info), to that record.
Other users may be able to view that record but not change anything for that record.

Currently, I have a custom login that carries over the users username - this is used to identify from what area/department he's from and filter the viewing of records in the database (only see's records that belong to his area/department - this isnt much of a security issue but simple more user friendly).

I was hoping that maybe I can make use of this to somehow restrict/permit the updating/altering of records that that user made.

I'm not sure but i believe i should start with the onopen fucntion of a form but here's where i'm disastrous -vba code.

To the best of my capabilities this is my attempt to show what i'm trying to do:

if username.value = author of the record
then frmInput.edit = true

else frmInput.edit = false

endif

However like i said before other users from the area/department need to see the records but not allowed to edit them.

Many thanks for your help.:)

Newbie VBA Coder,:p
Ode
 
Try something like this...

Code:
Private Sub Form_Open(Cancel As Integer)
On Error GoTo Err_Form_Open

    If CurrentUser = "User1" Then
        Me.AllowAdditions = True
        Me.AllowDeletions = True
        Me.AllowEdits = True
    If CurrentUser = "User2" Then
        Me.AllowAdditions = True
        Me.AllowDeletions = False
        Me.AllowEdits = False
    Else
        Me.AllowAdditions = False
        Me.AllowDeletions = False
        Me.AllowEdits = False
    End If
    
Exit_Form_Open:
    Exit Sub

Err_Form_Open:
    MsgBox Err.Number & " - " & Err.Description
    Resume Exit_Form_Open

End Sub
 
Many thanks for your help Ghudson

Although in the end i didnt use your code, i did fiddle around with it trying to make it work with my setup and ultimately helped me reach my objective.

Heres how i got away with it :D

Code:
Private Sub UpdateProbBtn_Click()
    
'@@@@@ Restricting editing properties of records to author of record only - non-author users have viewing access only.@@@@


     If userlog = Me.Author.Value Then 'userlog is the login name & Author is author of record
        
     DoCmd.OpenForm "frmInput", acNormal, , "ProblemNumber = " & Me.ProblemNumber, acFormEdit, acWindowNormal
   
    Else
        DoCmd.OpenForm "frmInput", acNormal, , "ProblemNumber = " & Me.ProblemNumber, acFormReadOnly, acWindowNormal
        
    End If
    
  
End Sub

This made me realize another thing: I had to change the Author input field to a combo box to guarantee a match with the login.

Now works perfectly

Thanks once again ghudson...
 

Users who are viewing this thread

Back
Top Bottom