Solved

Select Case via TreeView Node

Posted on 2006-07-06
5
576 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Validating VB6 Function 19 56
How does CurrentUser work? 10 31
Convert VB6 MSXML2.ServerXMLHTTP process to C# 2 42
Excel Automation VBA 19 37
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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…

895 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

12 Experts available now in Live!

Get 1:1 Help Now