Solved

Select Case via TreeView Node

Posted on 2006-07-06
5
573 Views
Last Modified: 2006-11-18
Below is my current code. When a user selects the "Administrator" Caption in my treeview I want it
to block access unless the user is a manager. What is the best way to do this ?

I do already have code in place to pull the users network ID and place it in label29.caption
Need  Msgbox displaying that access is not available unless label29.caption = manager1,manager2 or manager3...etc

Private Sub tvTreeView_NodeClick(ByVal Node As MSComctlLib.Node)
    Select Case Node.Key
       Case "Administrator"  
           If Lable29.caption = "manager1", manager2 or manager3 expand Administrator Tree
           else  MsgBox " You do not have permission to access this module" (Or any other module under admin )
          End If
 
       Case "Shared Files"
           My code......
           My code......

       Case " Admin Reports"    ' This is under the "Administrator" view, so I want it blocked as well
            Code ??? Same as above I assume
        End Select
End Sub


Any help would be appreciated
0
Comment
Question by:ittechie100
  • 3
  • 2
5 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility

Private Sub tvTreeView_NodeClick(ByVal Node As MSComctlLib.Node)
    Select Case Node.Key
       Case "Administrator"  
           if Lable29.caption like "manager*"
              node.expanded = true          
           else  
              node.expanded = false
              MsgBox " You do not have permission to access this module" (Or any other module under admin )
          End If
 
       Case "Shared Files"
           My code......
           My code......

       Case " Admin Reports"    ' This is under the "Administrator" view, so I want it blocked as well
            Code ??? Same as above I assume
        End Select
End Sub
0
 

Author Comment

by:ittechie100
Comment Utility
if Lable29.caption like "manager*"  I only have three managers, so I would need it to reflect their network usernames.

How do you write "jdoe, mjohnson or tsmith"

Thanks,

   
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 250 total points
Comment Utility
Private Sub tvTreeView_NodeClick(ByVal Node As MSComctlLib.Node)
    Select Case Node.Key
       Case "Administrator"  
           select case  Lable29.caption
               case like "jdoe", "mjohnson", "tsmith"
                 node.expanded = true          
                case else  
                   node.expanded = false
                   MsgBox " You do not have permission to access this module" (Or any other module under admin )
          End select
 
       Case "Shared Files"
           My code......
           My code......

       Case " Admin Reports"    ' This is under the "Administrator" view, so I want it blocked as well
            Code ??? Same as above I assume
        End Select
End Sub
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
note that it would be better to store the list of them in a table, and check if the current user is in that list, and put that into a boolean value... much easier to maintain...
0
 

Author Comment

by:ittechie100
Comment Utility
I had to replace the Case Like with Case Is, but now it is working great.

Thanks alot..
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now