Solved

Select Case via TreeView Node

Posted on 2006-07-06
5
588 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…

756 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