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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A question for Thekon

Status
Not open for further replies.

Djbell

IS-IT--Management
Apr 22, 2002
175
GB
Hi Thekon

Sorry I have another question for you.

The table which makes up the treeview also contain another 3 fields, these are users, Directory access and File access. Is it possible that when I click on any part of the tree that I can get it to show me the associated Users, File and group access on another control such as a text box list box ect. For example

Table View

Field1 Field2 Field3 Field4 Field5 Field6 Field7

SERVER1 GROUPS FJM Admin All All
SERVER1 GROUPS FJM Dougie All All
SERVER1 HOME DOUGIE Admin All All
SERVER1 HOME DOUGIE Dougie All All
SERVER1 HOME CATHB Admin All All
SERVER1 HOME CATHB Cathb RX RX

So the form would look like:-

Treeview

SERVER1
GROUPS
FJM
HOME
DOUGIE
CATHB

So in the treeview if FJM was clicked on then a list box would display what users had access to it. In this case it would be Admin and Dougie. Then clicking on either Admin or Dougie would show you the associated File and directory rights in either a text box or something. I have tried but it will just not work for me.

Regards

Djbell
 
Sorry Thekon

I also forgot to add, that my table has over 2000 records so it takes about 5 mins to load my Treeview form, is there anyway to speed this up.

Regards

Djbell





 
For the first question u can add a subform to your form bound to your table using all the fields. Then put this code in the nodeclick event of the treeview :

Private Sub test_NodeClick(ByVal Node As Object)
Dim strPath As String, strSQL As String
Dim str1 As String, str2 As String, str3 As String
Dim position As Integer

strPath = Node.FullPath
position = InStr(strPath, "\")
If position = 0 Then
strSQL = "SELECT * FROM Your_table WHERE Field1= '" & strPath & "'"
Else
str1 = Left(strPath, position - 1)
strPath = Right(strPath, Len(strPath) - position)
position = InStr(strPath, "\")
If position = 0 Then
strSQL = "SELECT * FROM Your_table WHERE Field1= '" & str1 & "' AND Field2= '" & strPath & "'"
Else
str2 = Left(strPath, position - 1)
strPath = Right(strPath, Len(strPath) - position)
position = InStr(strPath, "\")
If position = 0 Then
strSQL = "SELECT * FROM Your_table WHERE Field1= '" & str1 & "' AND Field2= '" & str2 & "' AND Field3= '" & strPath & "'"
Else
str3 = Left(strPath, position - 1)
strPath = Right(strPath, Len(strPath) - position)
position = InStr(strPath, "\")
strSQL = "SELECT * FROM Your_table WHERE Field1= '" & str1 & "' AND Field2= '" & str2 & "' AND Field3= '" & str3 & "' AND Field4= '" & strPath & "'"
End If
End If
End If
Me![Your_subForm].Form.RecordSource = strSQL
Me![Your_subForm].Form.Requery


For the second question, the code i gave you is not very efficient for 2000 records, since it has a lot of nested SELECT clauses. Because you talked about Access rights i thought 100-200 records. But for 2000 records i dont think we can do much. Indexing the fields may give a slight improvement. If i think something better i will let you know.

ps: i hope my English are good :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top