Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NodeCheck event problem

Status
Not open for further replies.

clegg

Programmer
Jan 25, 2001
98
GB
Hi all!

I've got a treeview that is loaded with defaults depending on the logged-on user.

If the user tries to check a box that they do not have access to I display a message and then uncheck the box.

The problem seems to be that as I step through the routine, the box gets unchecked but then when the event is exited the box becomes checked again.

Private Sub TV1_NodeCheck(ByVal Node As MSComctlLib.Node)
Dim bAllowed As Boolean

' check to see if user has access to this module
bAllowed = False
Select Case Left(Node.Key, 1)
Case "F"
bAllowed = modF
Case "S"
bAllowed = modS
Case "O"
bAllowed = modO
Case "B"
bAllowed = modB
Case "M"
bAllowed = modM
Case "P"
bAllowed = modP
Case "H"
bAllowed = True
End Select

If Not bAllowed Then
MsgBox "You do not have access to this module.", vbOKOnly + vbExclamation, "Maintain Users Programs"
For Each nodeX In TV1.Nodes
If Left(nodeX.Key, 1) = Left(Node.Key, 1) Then
nodeX.Checked = False
End If
Next nodeX
Exit Sub
End If

Anyone got a solution for this?

TIA
Clegg
 
One thing you can do is to load the nodes for a particular user right when he logs in.

That is, pre-determine the modules for each user, and then while checking the Username/Password itself, load the treeview nodes (modules) for that user.

------------------------------------------
The faulty interface lies between the chair and the keyboard.
 
I'm with vbSun. Check the used rights first and if they don't have rights to a node don't even load it in the treeview.

Users get annoyed when they see something and then get an access denied, or no rights message. Better that they don't even see it. Out of sight, out of mind.

zemp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top