VictoriaWass
Programmer
I have a function which I want to run each time any form is opened. This function checks the id of the user, and dissables any controls on that form not relevant to them.
I want the function to run for whichever form is calling it in the load event, but I can't work out how to refer to the calling form in the function. I tried passing the name of the form as a string argument to the function, but no joy. I could put the code in the load event of each form and use "me", but it would be much neater to call the function each time. The function sits in a module.
Here's what I've done so far, and don't laugh please if I'm being very stupid..
Function super_rights(l_form As string)
Dim ctl As Control
If CurrentUser <> "Admin" Then
For Each ctl In l_form.Controls
If ctl.ControlType = acCommandButton Then
If ctl.Tag = "super" Then
ctl.Enabled = False
End If
End If
Next ctl
End If
End Function
Any help would be much appreciated. Thanks
Vicky
I want the function to run for whichever form is calling it in the load event, but I can't work out how to refer to the calling form in the function. I tried passing the name of the form as a string argument to the function, but no joy. I could put the code in the load event of each form and use "me", but it would be much neater to call the function each time. The function sits in a module.
Here's what I've done so far, and don't laugh please if I'm being very stupid..
Function super_rights(l_form As string)
Dim ctl As Control
If CurrentUser <> "Admin" Then
For Each ctl In l_form.Controls
If ctl.ControlType = acCommandButton Then
If ctl.Tag = "super" Then
ctl.Enabled = False
End If
End If
Next ctl
End If
End Function
Any help would be much appreciated. Thanks
Vicky