Avatar of SteveL13
Flag for United States of America

asked on 

Trying to setup security level on form fields

Maybe this won't work but I am trying to establish field security on a form using the tag in the property sheet of the fields.  The user logs in via a login form and if the log in properly a number is written to a field named "Tag" in a table named "LOCALtblCurrentUser".  So for example the tag written to that user may be 12.  This is working perfectly.

But then on a form if the field Tag is anything other than 12 I want that field to be locked on open.  (Or maybe it should be on load ?)

Here is a public function I put at the bottom of the form code:
Public Sub Permissions()
    If DLookup("[Tag]", "LOCALtblCurrentUser") <> 12 And Forms!Controls.Tag = 12 Then
        Me!Controls.Locker = True
    End If
End Sub

Open in new window

And here is the onopen event of the form:
Private Sub Form_Open(Cancel As Integer)
    Call Permissions
End Sub

Open in new window

But this isn't working.  Can someone help?
Microsoft Access

Avatar of undefined
Last Comment
Scott McDaniel (EE MVE )

8/22/2022 - Mon