command button visible if security group = [admin] (1 Viewer)

MSUKevin

Registered User.
Local time
Today, 08:28
Joined
May 16, 2001
Messages
75
Hello everyone!

I am using A'97 and have built in user-level security, my question is this:

Is it possible to reference a security group account for a particular function in code? For example:
- I have a form that has a command button to go into previous records, (The default I set was that users are only allowed to go to the next entry-not to previous records). I have built a command button that allows the user to go to the previous entry but I only want this button visible if the user is a member of the supervisor group.

- I have not been able to find any help in either past posts on this forum or Access help on how to call up group accounts in code.

Any help you could give is truely appreciated!!!

Thank you,
Kevin
 

Opengrave

Registered User.
Local time
Today, 02:28
Joined
Sep 6, 2001
Messages
70
By 'built in' do you mean Access Workgroup Security or your own security? Try setting the 'Visible' property of the button to 'false' if the user is not a member of the supervisor group (as part of a form open event procedure). Here's some code cut-and pasted from one of my applications.
Code:
Private Sub Form_Open(Cancel As Integer)
    Dim db As Database
    Dim tbl As TableDef, fld As Field, qry As QueryDef
    Dim rst As Recordset, rst1 As Recordset, rst2 As Recordset
    Dim strOldUserNo As String, strMessage As String, strUserId As String

    Set db = CurrentDb
    'Find out who is logged on to the system
    Set rst2 = db.OpenRecordset("select User_Id from tbl_Current_User", dbOpenDynaset)

    With rst2
        .MoveFirst
        'If the current user is Tech Support let him see the security level field
        If !USER_ID = "A11737" Or !USER_ID = "A11725" Then
            Me![SEC_LEVEL].Visible = True
            Me![Label22].Visible = True
            Me![qryDeleteSecurity].Visible = True
            Me![SecurityLabel].Visible = True
            Me![Label32].Visible = True
            Me![Text31].Visible = True
        Else
        'If the current user is NOT Tech Support, don't let him see the security level field
            Me![SEC_LEVEL].Visible = False
            Me![Label22].Visible = False
            Me![qryDeleteSecurity].Visible = False
            Me![SecurityLabel].Visible = False
            Me![Label32].Visible = False
            Me![Text31].Visible = False
        End If
    End With
    
End Sub
 

MSUKevin

Registered User.
Local time
Today, 08:28
Joined
May 16, 2001
Messages
75
Opengrave,

Thanks for the reply - The "built-in" security I mentioned in my initial post is the Access Workgroup Security created by the wizard.

Question:

- The code that you have posted, does that reference groups for Access Workgroup Security or is that set for your own personal designed security? If that is for the Access workgroup security the the table you reference - [tbl_Current_User] is this the table name in the workgroup information file?

If so, how were you able to get access to this informaiton as I have yet to be able to open an individual workgroup information file to see whats in it.

Any and all feedback you could give me would be greatly appreciated!

Thank you,
Kevin
 

Opengrave

Registered User.
Local time
Today, 02:28
Joined
Sep 6, 2001
Messages
70
The code that you have posted does that reference groups for Access Workgroup Security or is that set for your own personal designed security?
My own security – that was why I asked what you are using. I’ve never done exactly what you are trying with workgroups. My database has a ‘splash’ screen that prompts for userid and password and writes it to a one-row table that keeps system parms like userid and current case number.
If that is for the Access workgroup security then the table you reference - [tbl_Current_User] is this the table name in the workgroup information file?
No, that is the table I was talking about above.
If so, how were you able to get access to this information as I have yet to be able to open an individual workgroup information file to see what’ in it.
I don’t know how to see what is actually in the file but you can get current user ID using the =CurrentUser() operator. To demonstrate this create a form and add a Text Box and set the default value of the Text Box to =CurrentUser(). When you launch the form you should see the ID of the person signed into the database. I realize this is not exactly what you want but I can’t seem to find anything in Access documentation that allows you to access workgroup info especially in code.
Wait, maybe I just found something. Go into the VB editor in Access and pull down the help function and do a search for USER OBJECT read that and see if it helps. Also click EXAMPLE and select USERS OBJECT, USERS COLLECTION EXAMPLE. This may not be what you need but it seems like it getting awfully close.
 

MSUKevin

Registered User.
Local time
Today, 08:28
Joined
May 16, 2001
Messages
75
Opengrave,

Quote:
__________________________________________________________
My own security – that was why I asked what you are using
__________________________________________________________

I was hoping you wouldn't say that!


As far as the =CurrentUser() func. I use this a couple times in my db and that works great for the users, but I will eventually have a lot of users and to write the UserID in the IF-THEN string for every user would not be practical.

I am currently going into the VB editor and am going to do a bit more research on the user object func. and check out some of the examples, reconsult my Access bible on this topic, and do try to work out some form of code to accomplish this task.

Thanks for all your help/suggestions on this topic. I never thought to check the VB editor --"guess I got a little fuzzy and frustrated!"-- Sometimes you just need someone to take the blinders off and point you in the right direction


Thanks again and if you have any other suggestions please let me know. When I figure out the code or find some good source info on this subject I'll post it back here so you can check out what I found, and so others who need the same thing can take a look.

Thanks again,
Kevin
 

Users who are viewing this thread

Top Bottom