Solved

Select Case via TreeView Node

Posted on 2006-07-06
5
598 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17054089

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
ID: 17054168
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 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 250 total points
ID: 17054222
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 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17054230
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
ID: 17058100
I had to replace the Case Like with Case Is, but now it is working great.

Thanks alot..
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month6 days, 21 hours left to enroll

622 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