Hello All. So I'm creating a database for the fire department I belong to. It's basically to log calls and create reports based on those calls. I will also log other things like problem tickets, apparatus checks, etc... Anyways I have it set up with access permissions. Each employee has a login and when that person logs in, it looks at the "employee" database and sees what "level" they are assigned. Currently I have 3 levels.
Level 1 - General user
Level 2 - Quality Assurance Personal
Level 3 - Admin (chief)
On each form, the buttons for features are either enabled or disabled depending on that security level. I'm doing this buy assigning a the button's tag value either 1, 2, or 3. After the user logs in on the main form, it runs a function to enable or disable certain buttons based on their tag value. Any form that opens also runs this function.
It works to enable the buttons that need to be enabled but when it comes to disabling (user logs out) it doesn't work and says the control doesn't support the property. After doing some debugging, the function looks at all controls, including labels (which don't have an "enabled" property) so that's why it's erroring out.
When the function runs, it looks to see if the .tag is not null and is >= user_perm (a global variable). The controls that I don't need enabled / disabled don't have anything in their tag values (which, i assume is considered null?) so it shouldn't even be looking at the labels because there is no value in their tag property.
Below is the function code. On the form's controls, I only have a value in the tag property if I need it enabled / disabled for access restrictions.
Thanks
Level 1 - General user
Level 2 - Quality Assurance Personal
Level 3 - Admin (chief)
On each form, the buttons for features are either enabled or disabled depending on that security level. I'm doing this buy assigning a the button's tag value either 1, 2, or 3. After the user logs in on the main form, it runs a function to enable or disable certain buttons based on their tag value. Any form that opens also runs this function.
It works to enable the buttons that need to be enabled but when it comes to disabling (user logs out) it doesn't work and says the control doesn't support the property. After doing some debugging, the function looks at all controls, including labels (which don't have an "enabled" property) so that's why it's erroring out.
When the function runs, it looks to see if the .tag is not null and is >= user_perm (a global variable). The controls that I don't need enabled / disabled don't have anything in their tag values (which, i assume is considered null?) so it shouldn't even be looking at the labels because there is no value in their tag property.
Below is the function code. On the form's controls, I only have a value in the tag property if I need it enabled / disabled for access restrictions.
Code:
Public Sub ValidateFormControls(myform As Form)
Dim ctl As Control
With myform
For Each ctl In .Controls
With ctl
If IsNull(.Tag) = False And .Tag <= user_perm Then
.Enabled = True
Else
.Enabled = False
End If
End With
Next ctl
End With
End Sub
Thanks