Solved

Select Case via TreeView Node

Posted on 2006-07-06
5
581 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]
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 142

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 142

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

823 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