I am trying to create a form so that I can display a high level down to a low level in one column (ALL of Sam's reports, direct and indirect) without having to use code...I am hoping table structure alone will allow this flexibility...does anyone know of any existing examples I could peruse to help???
26 20571
Looks to me you need a self-related table like:
ID
IDofParent
FieldX
Now you can place this table e.g. 4 times and connect from the first the IDofParent to the ID of the second, the IDofParent of the second to the ID of the third, etc.
This does require a max of levels, but is doable without code.
The general approach would however bee to use a tree control, but that required advanced VBA skills....
Nic;o)
I am trying to create a form so that I can display a high level down to a low level in one column (ALL of Sam's reports, direct and indirect) without having to use code...I am hoping table structure alone will allow this flexibility...does anyone know of any existing examples I could peruse to help???
A TreeView Control would, as Nico stated, graphically display this Hierarchal Structure on a Form and we could also keep its syntax as simple as possible. Give me a sample subset of the data with all Levels defined and I'll post the code for you. Once you see it, I'm sure that you will be able to fill in the blanks.
- Level 1 Level 2 Level 3 Level 4
-
OPS SOAR Provider Service Provider Services
-
OPS SOAR Provider Service ALL Reviews
-
OPS SOAR Service Quality QA
-
OPS DOES Document Operations NA
-
OPS DOES Process Reengineering NA
-
OPS DOES Electronic Solutions ES Support
-
OPS DOES Electronic Solutions ES Maintenance
-
Finance Monroe ASO ASO Customer Service
-
Finance Monroe ASO ASO Claims
-
Finance Monroe ASO ASO Rewards
-
Finance Monroe PCG Customer Guarantees
so if i choose a manager from the last row, i should see all individuals for all 3 lower levels in a single row, i.e.:
Monroe + PCG + Customer Gurtantees
if I need to add further info let me know - without code this is a headache inducer...
- Level 1 Level 2 Level 3 Level 4
-
OPS SOAR Provider Service Provider Services
-
OPS SOAR Provider Service ALL Reviews
-
OPS SOAR Service Quality QA
-
OPS DOES Document Operations NA
-
OPS DOES Process Reengineering NA
-
OPS DOES Electronic Solutions ES Support
-
OPS DOES Electronic Solutions ES Maintenance
-
Finance Monroe ASO ASO Customer Service
-
Finance Monroe ASO ASO Claims
-
Finance Monroe ASO ASO Rewards
-
Finance Monroe PCG Customer Guarantees
so if i choose a manager from the last row, i should see all individuals for all 3 lower levels in a single row, i.e.:
Monroe + PCG + Customer Gurtantees
if I need to add further info let me know - without code this is a headache inducer...
I will get back to you on this shortly.
I will get back to you on this shortly.
Hang on to your seat belts and follow these instructions exactly:
__01 Create a New, Unbound Form.
__02 Place a TreeView Control on the Form via Insert ==> ActiveX Control ==> Microsoft TreeView Control.
__03 Size the Control to the full Form dimensions.
__04 Rename the TreeView Control to TreeView1. If it is named anything other than this, the code will not be functional.
__05 Place the following code in the Form's Load() Event (listed below).
__06 When the Form opens, you will see the Root and Level1 Nodes. You can now see your Hierarchal structure by Expanding/Collapsing (+/-) various branches to move Up and Down multiple Levels as in Windows Explorer.
__07 Each Level in the code has its own degree of indentation to make your understanding of the coding process easier so that you may adapt the code to your own specific needs.
__08 If you have any questions, feel free ask as the TreeView Control is a fairly complex Control to implement.
__09 If you are interested, you can also display Icons for each individual Node but this involves inserting an ImageList Control, assigning Icons to it, pointing the TreeView Control to it, and setting Index values for each Icon for each line of code. - Private Sub Form_Load()
-
Dim nodX As Node
-
-
'1-Relative, tvwChild-Relationship, "g"-Key, "George"-Text
-
Set nodX = TreeView1.Nodes.Add(, , , "Hierarchal Structure Example (ROOT)") 'Root of Treeview Control
-
-
Set nodX = TreeView1.Nodes.Add(1, tvwChild, "Topic1", "OPS")
-
Set nodX = TreeView1.Nodes.Add("Topic1", tvwChild, "Level2A", "SOAR")
-
Set nodX = TreeView1.Nodes.Add("Level2A", tvwChild, "Level3A", "Provider Service")
-
Set nodX = TreeView1.Nodes.Add("Level3A", tvwChild, "Level4A", "Provider Services")
-
Set nodX = TreeView1.Nodes.Add("Level3A", tvwChild, "Level4B", "ALL Reviews")
-
Set nodX = TreeView1.Nodes.Add("Level2A", tvwChild, "Level3B", "Service Quality")
-
Set nodX = TreeView1.Nodes.Add("Level3B", tvwChild, "Level4C", "QA")
-
Set nodX = TreeView1.Nodes.Add("Topic1", tvwChild, "Level2B", "DOES")
-
Set nodX = TreeView1.Nodes.Add("Level2B", tvwChild, "Level3C", "Document Operations")
-
Set nodX = TreeView1.Nodes.Add("Level3C", tvwChild, "Level4D", "NA")
-
Set nodX = TreeView1.Nodes.Add("Level2B", tvwChild, "Level3D", "Process Engineering")
-
Set nodX = TreeView1.Nodes.Add("Level3D", tvwChild, "Level4E", "NA")
-
Set nodX = TreeView1.Nodes.Add("Level2B", tvwChild, "Level3E", "Electronic Solutions")
-
Set nodX = TreeView1.Nodes.Add("Level3E", tvwChild, "Level4F", "ES Support")
-
Set nodX = TreeView1.Nodes.Add("Level3E", tvwChild, "Level4G", "ES Maintenance")
-
Set nodX = TreeView1.Nodes.Add(1, tvwChild, "Topic2", "Finance")
-
Set nodX = TreeView1.Nodes.Add("Topic2", tvwChild, "Level2C", "Monroe")
-
Set nodX = TreeView1.Nodes.Add("Level2C", tvwChild, "Level3F", "ASO")
-
Set nodX = TreeView1.Nodes.Add("Level3F", tvwChild, "Level4H", "ASO Customer Service")
-
Set nodX = TreeView1.Nodes.Add("Level3F", tvwChild, "Level4I", "ASO Claims")
-
Set nodX = TreeView1.Nodes.Add("Level3F", tvwChild, "Level4J", "ASO Rewards")
-
Set nodX = TreeView1.Nodes.Add("Level2C", tvwChild, "Level3G", "PCG")
-
Set nodX = TreeView1.Nodes.Add("Level3G", tvwChild, "Level4K", "Customer Guarantees")
-
-
nodX.EnsureVisible
-
-
TreeView1.Nodes(1).ForeColor = QBColor(4)
-
-
Exit_Form_Load:
-
Exit Sub
-
-
Err_Form_Load:
-
MsgBox Err.Description, vbExclamation, "Error in TreeView_Form_Load()"
-
Resume Exit_Form_Load
-
End Sub
WOW - I knew it wouldn’t' be easy - I follow you to a point - in your instructions I don't see anything tying the code to my table – or am I just putting the layout and table data directly in the code itself as you have done with the few examples I provided?
WOW - I knew it wouldn’t' be easy - I follow you to a point - in your instructions I don't see anything tying the code to my table – or am I just putting the layout and table data directly in the code itself as you have done with the few examples I provided?
This is simlpy hard-coded values to give you an idea of how this Control functions. Reading values from a Table/Recordset wopuold add complexity to the coding.
Thanks - this code worked perfect!!!
Thanks - this code worked perfect!!!
Glad to help you.
hey guys, glad to see the code working, but i can't really find where is the activex control in vba. Please advise.
Thanks
hey guys, glad to see the code working, but i can't really find where is the activex control in vba. Please advise.
Thanks
- Form Design View.
- Insert.
- ActiveX Control.
- You are now in the Insert ActiveX Control Dialog Box.
- Select the Microsoft TreeView Control, version X.X.
- The TreeView Control should now exist in the Upper Left Hand corner of the Form.
Thanks so much. it took me a while. :D There is one more thing that i dont know if the treeview can do. For ex, if im gonna select Service Quality ( Under OPS-SOAR), will it be possible to make a button that will copy the hierachy into the following format: OPS/ SOAR/ Service Quality?
Thanks so much man. you are the man
Thanks so much. it took me a while. :D There is one more thing that i dont know if the treeview can do. For ex, if im gonna select Service Quality ( Under OPS-SOAR), will it be possible to make a button that will copy the hierachy into the following format: OPS/ SOAR/ Service Quality?
Thanks so much man. you are the man
Yes, it should be no problem. They wouold simply be Children of Parent Nodes, follow the examples.
Thank you, i probably didn't make myself clear enough. It is a lil bit confusing for me.
I have successfully constructed the tree, but the information that is useful for the end user if they can extract the information out of the tree and use it.
Using the treview that we have here as an example, if I want to select service quality (which is under OPS and SOAR), is there a way to extract the levels i have go through in a text string that can look something like this:
OPS/ SOAR/ Service Quality
On the same line, if I want to convert to text string just SOAR ( under OPS), it will give me OPS/SOAR ?
and hopefully the same thing will happen if i click something else in the treeview.
I dont know if this can be accomplished by using buttons and text boxes or using something else.
Please help. I really Appreciate it. you are the man
Thank you, i probably didn't make myself clear enough. It is a lil bit confusing for me.
I have successfully constructed the tree, but the information that is useful for the end user if they can extract the information out of the tree and use it.
Using the treview that we have here as an example, if I want to select service quality (which is under OPS and SOAR), is there a way to extract the levels i have go through in a text string that can look something like this:
OPS/ SOAR/ Service Quality
On the same line, if I want to convert to text string just SOAR ( under OPS), it will give me OPS/SOAR ?
and hopefully the same thing will happen if i click something else in the treeview.
I dont know if this can be accomplished by using buttons and text boxes or using something else.
Please help. I really Appreciate it. you are the man
You could extract all Children of Main Node and concatenate the result as in: Main Node/Child 1/Child 2/Child 3/...etc.
Is this what you are looking for? If it is you can Reference the Help Files for the Child and Parent properties. If you still have difficulties, let me know.
I hope you can see the tree that i just made.
One that tree, i created a submit button (it can't do anything yet), but i would love if it can extract from my selection.
In this ex, i select professional by going through legal- professional, when i click submit button, it should return the string "legal/ professional" like in the example http://www.flickr.com/photos/31626245@N06/2959564798/
similarly, for automobile, if i click automobile and then submit, it will return the string " automobile" in the box. http://www.flickr.com/photos/31626245@N06/2959569056/
Is there any ways to accomplish this?
Thanks
I hope you can see the tree that i just made.
One that tree, i created a submit button (it can't do anything yet), but i would love if it can extract from my selection.
In this ex, i select professional by going through legal- professional, when i click submit button, it should return the string "legal/ professional" like in the example http://www.flickr.com/photos/31626245@N06/2959564798/
similarly, for automobile, if i click automobile and then submit, it will return the string " automobile" in the box. http://www.flickr.com/photos/31626245@N06/2959569056/
Is there any ways to accomplish this?
Thanks
It'as probably a lit simpler than you realize, the the NodeClick() Event of the treeView Control, place the following code for a visual cue: - Private Sub TReeview1_NodeClick(ByVal Node As Object)
-
MsgBox Replace(Node.FullPath, "\", "/")
-
End Sub
It'as probably a lit simpler than you realize, the the NodeClick() Event of the treeView Control, place the following code for a visual cue: - Private Sub TReeview1_NodeClick(ByVal Node As Object)
-
MsgBox Replace(Node.FullPath, "\", "/")
-
End Sub
Wow thats only a 3 line of codes. lol Thanks man, but i have a compiler error saying that " procedure declaration does not match description of event or procedure having the same name".. that sucks.
So I went ahead trying to find solutions for this compiler error, but nothing is really showing up.
Crap, so I created a label so i can show this, using the following code
Label1.Caption = nodX.FullPath
(nodX is the variable)
Well, it shows, but it only shows the last one, and it did not show anything else when i click through nodes. Is there any updates can be done, or even an If function might be helpful.
Thanks
Wow thats only a 3 line of codes. lol Thanks man, but i have a compiler error saying that " procedure declaration does not match description of event or procedure having the same name".. that sucks.
So I went ahead trying to find solutions for this compiler error, but nothing is really showing up.
Crap, so I created a label so i can show this, using the following code
Label1.Caption = nodX.FullPath
(nodX is the variable)
Well, it shows, but it only shows the last one, and it did not show anything else when i click through nodes. Is there any updates can be done, or even an If function might be helpful.
Thanks
The correct syntax in the NodeClick() Event is: - Me![Label1].Caption = Node.FullPath
The correct syntax in the NodeClick() Event is: - Me![Label1].Caption = Node.FullPath
So should i use the IF loop for this? I tries to implement the code in various lines, but the label only shows the node that is above this code.
Is there anyways to show the appropriate path when choosing any specific node?
Thanks
So should i use the IF loop for this? I tries to implement the code in various lines, but the label only shows the node that is above this code.
Is there anyways to show the appropriate path when choosing any specific node?
Thanks
Yes, by using either an If...ElseIf...Else...End If, or Select Case Structure. It all depends on which Nodes you want to exclude.
Yes, by using either an If...ElseIf...Else...End If, or Select Case Structure. It all depends on which Nodes you want to exclude.
ADezii,
I want to inlcude every node. But only when i select them, it will show the full path. Please advice on how to use if properly for this treeview.
Thanks
ADezii,
I want to inlcude every node. But only when i select them, it will show the full path. Please advice on how to use if properly for this treeview.
Thanks
The code as it is now, placed in the NodeClick() Event will activate 'only' when the Node is Clicked/Selected. I don't know what else to tell you.
The code as it is now, placed in the NodeClick() Event will activate 'only' when the Node is Clicked/Selected. I don't know what else to tell you.
Thanks, ADezii,
I found the solution for this. This following code works:
Private Sub Tree_NodeClick(ByVal Node As MSComctlLib.Node)
Me.Label1.Caption = Node.FullPath
End Sub
I have no Idea why we have to use the MSComctLib.Node, but it shows the path perfectly.
Thanks so much for helping me with this VBA. I really appreciate it.
Thanks, ADezii,
I found the solution for this. This following code works:
Private Sub Tree_NodeClick(ByVal Node As MSComctlLib.Node)
Me.Label1.Caption = Node.FullPath
End Sub
I have no Idea why we have to use the MSComctLib.Node, but it shows the path perfectly.
Thanks so much for helping me with this VBA. I really appreciate it.
ADezii,
Its maybe really easy, but I just can't seem to find a way to record that path I show into the textbox and then add another fullpath into the same textbox. Any advice?
ADezii,
Its maybe really easy, but I just can't seem to find a way to record that path I show into the textbox and then add another fullpath into the same textbox. Any advice?
I'm assuming that you mean to add another Full Path to the Label Control which already contains a Full Path, if so: - Me.Label1.Caption = Me.Label1.Caption & "\" & Node.FullPath
Post your reply Sign in to post your reply or Sign up for a free account.
Similar topics
9 posts
views
Thread by Jim |
last post: by
|
5 posts
views
Thread by SoKool |
last post: by
|
1 post
views
Thread by Srinivasa Raghavan |
last post: by
|
2 posts
views
Thread by Chris |
last post: by
|
3 posts
views
Thread by Peter |
last post: by
|
4 posts
views
Thread by Ben Coats |
last post: by
|
10 posts
views
Thread by p3t3r |
last post: by
|
5 posts
views
Thread by david |
last post: by
|
reply
views
Thread by noneya22 |
last post: by
| | | | | | | | | | | |