HillTJ
To train a dog, first know more than the dog..
- Local time
- Yesterday, 18:09
- Joined
- Apr 1, 2019
- Messages
- 731
Hi,
I have a mainform 'frmPersons' on it are a number of tabbed subforms. As an example one is called 'frmAddress_Subform, and the subform control is called 'SubfrmTab' to be original!
My intention is to pass the form name to the below function to assign user rights. All works on the main form where I use the Form Open event to call : AssignUserRights(me.Name), but I cannot get it to work from the formLoad event : Call AssignUserRights("forms!frmPersons.frmAddress_Subform"). I had the code on the form Open event originally but tried it to no avail on the form Load Event.
I get the error message 2450 ....cannot find referenced form.. So I think I'm referencing the form wrongly. I've tried various iterations but no success.
Whats wrong? Appreciate a Heads-Up.
I have a mainform 'frmPersons' on it are a number of tabbed subforms. As an example one is called 'frmAddress_Subform, and the subform control is called 'SubfrmTab' to be original!
My intention is to pass the form name to the below function to assign user rights. All works on the main form where I use the Form Open event to call : AssignUserRights(me.Name), but I cannot get it to work from the formLoad event : Call AssignUserRights("forms!frmPersons.frmAddress_Subform"). I had the code on the form Open event originally but tried it to no avail on the form Load Event.
I get the error message 2450 ....cannot find referenced form.. So I think I'm referencing the form wrongly. I've tried various iterations but no success.
Whats wrong? Appreciate a Heads-Up.
Code:
Public Function AssignUserRights(ByVal frm As String)
Dim AccessLevel As Integer
AccessLevel = intAccessLevel
MsgBox intAccessLevel
Select Case AccessLevel
Case Is = "1" 'Viewer - view all records
MsgBox "1"
Forms(frm).AllowEdits = False
Forms(frm).AllowAdditions = False
Forms(frm).AllowDeletions = False
Case Is = "2" 'User - Can View Add and Amend Own Records
MsgBox "2"
Forms(frm).AllowEdits = True
Forms(frm).AllowAdditions = True
Forms(frm).AllowDeletions = False
Case Is = "3" Or "4" Or "5" 'Power User, Administrator or Developer - Can View Add Amend and Delete Their Own Records
MsgBox "3 , 4 or 5"
Forms(frm).AllowEdits = True
Forms(frm).AllowAdditions = True
Forms(frm).AllowDeletions = True
End Select
End Function