Assigning more than one tag in Access 2007 (1 Viewer)

Minddumps

Registered User.
Local time
Today, 02:04
Joined
Jul 5, 2011
Messages
73
So it's my understanding that you cannot input more than one tag into a cmd button's properties. I came across the idea of setting up a table of parameters for the tag to direct to though.

Does anyone know how to set that up or perhaps have a better solution?
 
Last edited:

GinaWhipp

AWF VIP
Local time
Today, 02:04
Joined
Jun 21, 2011
Messages
5,899
Re: Assigning more than one tab in Access 2007

Never tried it but a thought comes to mind...

You could assign the .Tag property based on the a field in the table or the caption on the command button thereby *assigning more than one tag* to that property. Now, if that is not appealing to try tell us a wee bit more of what you are trying to accomplish for more ideas.
 

boblarson

Smeghead
Local time
Yesterday, 23:04
Joined
Jan 12, 2001
Messages
32,059
How I do it is store them as delimited - for example, if I had forms that I wanted to have certain fields show based on security level, I would use this in the tag of them:

for Admin, Data Entry and Read Only:

Admin|DE|RO

for Admin and Data Entry
Admin|DE

And then in the code I can split them out:
Code:
Function EnableControls(strSecurityLevel As String)
Dim ctl As Control
Dim varSplit As Variant
Dim i As Integer
 
For Each ctl In Me.Controls
   If Len(ctl.Tag & vbNullString) > 0 Then
      varSplit = Split(ctl.Tag, "|")
        For i = 0 to UBound(varSplit)
           ctl.Enabled = (varSplit(i) = strSecurityLevel)
        Next
  End If
Next
 

GinaWhipp

AWF VIP
Local time
Today, 02:04
Joined
Jun 21, 2011
Messages
5,899
@Bob

Never thought of doing that! Thanks for the idea :D
 

Minddumps

Registered User.
Local time
Today, 02:04
Joined
Jul 5, 2011
Messages
73
Thanks so much to both of you, for your replies... somehow I missed the notifications about this thread in my email.
You could assign the .Tag property based on the a field in the table or the caption on the command button thereby *assigning more than one tag* to that property. Now, if that is not appealing to try tell us a wee bit more of what you are trying to accomplish for more ideas.

How I do it is store them as delimited - for example, if I had forms that I wanted to have certain fields show based on security level, I would use this in the tag of them:[/code]

Currently I have this code entered in both Form_open and Form_current:
Code:
Private Sub Form_Open(Cancel As Integer)
Dim ctl As Control
'Users 1 and 7 have access to all buttons
If UserAccessID = 1 Or UserAccessID = 7 Then
    For Each ctl In Me.Controls
        If ctl.ControlType = acCommandButton Then
            ctl.Enabled = True
        End If
    Next
Else
'Enable the button only if the UserID is in the Tag property
    For Each ctl In Me.Controls
        If ctl.ControlType = acCommandButton Then
            'use the InStr function to see if the UserID is in the Tag
            ctl.Enabled = InStr(ctl.Tag, UserAccessID) > 0
        End If
    Next
End If
End Sub
the InStr was to allow me to input multiple UserAccessID's in my tags; however, I just learned today that it doesn't block the command button as long as the tag is above 0 (er so I assume as above it states UserAccessID >0) Well that definitely doesn't solve my issue :(

Bob, the code you suggested... is it for a split database? and for the default 'user accounts set-up' by access itself? I haven't split my database because I'm still working the kinks out (and frankly i'm somewhat scared to do it as I've never done it before lol). Also, the User accounts that I have is basically copied from a "SecurityDemo" from UtterAccess. Perhaps you have heard of it, it was originally designed by Richard Rensal and updated by Nick Phillips.

With all of this being said, I think it might be easier just to fix my code above to allow only the buttons to be available if the UserAccessID is signed in. But considering I'm more like a newb, what is your opinion/suggestion?
 
Last edited:

Minddumps

Registered User.
Local time
Today, 02:04
Joined
Jul 5, 2011
Messages
73
oh and almost forgot to mention... in my Users set-up I have AccessViews that allows basic edits/adds of data in records (within my forms) and I have User Access Levels (will be at least 50 by the time I finish) that allows each user to access their section of the database. (hence the tag restrictions needed for certain command buttons).
 

Users who are viewing this thread

Top Bottom