Share via

make subform read only or allow edit based on user type

Anonymous
2011-04-01T08:15:53+00:00

I have a table USERS with a field UserType. If UserType is POWR, it can add, edit, delete a record in subform. If it's OPER, subform should read only. ABSENCE is my form tab. When click:

Private Sub Absence_Click()

    'Activate buttons based on record in Employees

    Select Case DLookup("[UserType]", "Users", "[userid] = " & Chr(34) & fOSUserName() & Chr(34))

        Case "Powr" ' Power users

            Forms![Absence subform].Locked = False

        Case "Oper" 'Operation

            Forms![Absence subform].Locked = True

    End Select

End Sub

How come usertype OPER still can add,edit,delete? I think I made a mistake when referring to subform. Help please.

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

HansV 462.6K Reputation points
2011-04-01T12:47:07+00:00

Change

            Forms![Absence subform].Locked = ...

to

            Me![Absence subform].Locked = ...

You should use the name of the subform as a control on the main form, this is not necessarily the same as the name of the source object of the subform.

Was this answer helpful?

0 comments No comments

0 additional answers

Sort by: Most helpful