Solved Getting Permissions form worked by control multiple controls by Tags

alvingenius

IT Specialist
Local time
Today, 11:50
Joined
Jul 10, 2016
Messages
169
Hello,

This Post is following this post to know how to control a group of controls

I have a users table with permissions of accessing forms/reports
and in this table 2 more checkboxes as rules Manger / Custom ( later maybe i convert it to combo box )

Manager have access to everything / custom have to set what to access

in permission form i've set record source to a query for this table and i've set a combo box to get user names from users qry
and listed all controls by users query

and all controls disabled by default except users combo box

attachment.php


in combo box of users "after update" event i've set this code

Code:
EnableControls True, "sec1"

to enable this section( Sec1 is tag for manager/custom controls )

then in Manager ON Click event i want all controls of checkboxes to be True

Code:
Private Sub optManager_Click()
Dim ctrl As Control
    If Me.optManager = True Then
        For Each ctrl In Me.Controls
        If ctrl.Tag = "secMain" Or ctrl.Tag = "secForm" Or ctrl.Tag = "secReport" Then [COLOR="green"]' all control tags[/COLOR]
            ctrl = True [COLOR="green"]' check all controls[/COLOR]
            ctrl.Enabled = False [COLOR="Green"]' can't edit controls anymore[/COLOR]
            Me.optCustom = False [COLOR="Green"]' remove check from other checkbox[/COLOR]
        End If
        Next ctrl
    End If
End Sub

Tags is shown in screenshot attached

now , when i open form and choose user Rules section (Sec1) shown up and when click on Manager i'm getting error

attachment.php


my idea is
when to check manager then all controls in tags secMain, secForm and secReport = True and all this controls Disabled
and if unchecked it by clicking on Custom then all tag controls Enabled to choose whatever i want .

what i'm doing wrong here !:confused::banghead:
 

Attachments

  • per.PNG
    per.PNG
    21.8 KB · Views: 818
  • perm2.PNG
    perm2.PNG
    7.6 KB · Views: 523
Last edited:
Sounds like you have tagged a label.?
They cannot be enabled I believe.?

If you click the debug button you can find out for definite as to which control is causing the problem?
 
Sounds like you have tagged a label.?
They cannot be enabled I believe.?

no this label is only to show it to u
attachment.php
 

Attachments

  • perm3.PNG
    perm3.PNG
    19.9 KB · Views: 479
? ctrl.name in the Immediate Window of the debugger and see what the ctrl is.?

or put Debug.Print ctrl.name before that line highlighted and view the immediate window.

From your previous pic, it looked like the labels for the options have tags completed?

FYI I am not helping via PMs, as this might help others in the future.
 
Last edited:
? ctrl.name
Label681

this label for "Open Master File " but why it's refer there ?
 
I'm with Gasman on the idea that you might have inadvertantly tagged something that should not have been tagged.

In the apps where I do a For Each x In Me.Controls type of loop, I always add a test inside the loop for Me.Type = acCommandButton (or acTextBox, or whatever type of control I was looking to change). The error you have named is actually quite common for loops that scan all controls. Makes it a pain in the toches, but if you make a subroutine out of it, you might only have to write it once and then just call it when you need it.

This also happens a lot when diddling with the .Value of something because some controls don't have a value. Labels and lines, e.g., have no value. Neither to Option Buttons. (There, the option GROUP has the value.)
 
You went and selected a bunch of controls with the mouse and half of those are labels for options?

Labels cannot be enabled as I suspected.

I do not think you need to test the type of control (which is normally done when looping through the collection) as long as you tag the correct controls. You haven't at present.
 
Ooh

i've selected all controls in layout and it included labels on this controls and that's why error occurred

to fix it i've edited all labels tags to a different name and it work now

Thanks
 
? ctrl.name
FYI I am not helping via PMs, as this might help others in the future.

i did PM because i don't understand what u typed

and i don't wanna make the post tall !!

then u edited the post

Thanks anyways
icon14.gif
 
to fix it i've edited all labels tags to a different name and it work now

So, this is SOLVED now?
 
I would agree with that wholeheartedly Tony for most occasions, but in this case if the correct controls were tagged with the correct data, there would be no need to inspect the type of control in this case.?
 
Tony,
I did not consider it as a criticism, I doubt the other responders did either, as that good practice was mentioned previously.
 
Either way works. As it happened, I used tags for enabling and disabling controls by role, but I had such a thing as a form "state" (not related to any state declared by Access). I would define the visual formats of controls that had values based on the form having been opened as "ReadOnly" or "Normal" or "Dirty" or whatever other states cropped up. (I recall five states in total.) For things that were visible, I would change borders, backgrounds, and foregrounds based on whether the control was virgin, dirty, read-only, out-of-bounds, or normal (meaning you had tabbed through it without changing it).
 
Last edited:

Users who are viewing this thread

Back
Top Bottom