I just discovered TreeView Controls after browsing through this site today...in a word, awesome!
I've done alot of searching, and it seems that most of the discussion on TreeView is at a data level.
What I am wondering is if a TreeView can be used as a database navigational pane...ie switchboard, where the nodes are comprised of individual forms and/or reports, that when clicked, opens the associated form/report?
Does anybody have a sample db where this is being done or can somebody give me some tips on doing this?
I have a sample treeview.mdb in 2000, and I can freely create the parent and child nodes. That is the extent of my knowledge. I don't know how to make the nodes "actionable".
If anyone wants to test this out to verify its a true bug it would be helpful:
Create a tab control. Place a treeview control (with checkboxes = Yes) on one of the pages. Populate the treeview. Check some boxes. Move to the next page of the tab control. Return to the page with the treeview. Viola! The checkboxes you checked previously are all unchecked. (Not just visually, but property-wise as well).
One step forward, two steps back.
Actually, the work around is to remove the treeview from the tab control and then change the Visible property of the treeview to False if on a different tab page, and True if on the page you want it to display on. But c'mon why can't it work the way you'd expect it to work!
Hi I am trying to create a treeview based on a table that I created. I am trying to create a treeview that fills the treeview recursively but for some reason I am only able to see the parent node and not the children
Here are the specs that I have so far
I have a table called "tblTreeview" I have tree fields "txtID" "txtNode" "txtRelationship" I also have a form called "frmTreeview" I named my treeview control "axtreeview"
here is the code that I copied off the link that I referenced at the beginning of this thread.
The only thing that is different is the name of the fields.
'--Beginning Code -- Private Sub Form_Load() Const strTableQueryName = "tblTreeview" Dim db As DAO.Database, rst As DAO.Recordset Set db = CurrentDb Set rst = db.OpenRecordset(strTableQueryName, dbOpenDynaset, dbReadOnly) AddBranch rst:=rst, strPointerField:="txtRelationship", strIDField:="txtID", strTextField:="txtNode" End Sub
'================= AddBranch Sub Procedure ====================== ' Recursive Procedure to add branches to TreeView Control 'Requires: ' ActiveX Control: TreeView Control ' Name: xTree 'Parameters: ' rst: Self-referencing Recordset containing the data ' strPointerField: Name of field pointing to parent's primary key ' strIDField: Name of parent's primary key field ' strTextField: Name of field containing text to be displayed '================================================= ============ Sub AddBranch(rst As Recordset, strPointerField As String, _ strIDField As String, strTextField As String, _ Optional varReportToID As Variant) On Error GoTo errAddBranch Dim nodCurrent As Node, objTree As TreeView Dim strCriteria As String, strText As String, strKey As String Dim nodParent As Node, bk As String Set objTree = Me!axTreeView.Object If IsMissing(varReportToID) Then ' Root Branch. strCriteria = strPointerField & " Is Null" Else ' Search for records pointing to parent. strCriteria = BuildCriteria(strPointerField, _ rst.Fields(strPointerField).Type, "=" & varReportToID) Set nodParent = objTree.Nodes("a" & varReportToID) End If
' Find the first emp to report to the boss node. rst.FindFirst strCriteria Do Until rst.NoMatch ' Create a string with LastName. strText = rst(strTextField) strKey = "a" & rst(strIDField) If Not IsMissing(varReportToID) Then 'add new node to the parent Set nodCurrent = objTree.Nodes.Add(nodParent, tvwChild, strKey, strText) Else ' Add new node to the root. Set nodCurrent = objTree.Nodes.Add(, , strKey, strText) End If ' Save your place in the recordset so we can pass by ref for speed. bk = rst.Bookmark ' Add employees who report to this node. AddBranch rst, strPointerField, strIDField, strTextField, rst(strIDField) rst.Bookmark = bk ' Return to last place and continue search. rst.FindNext strCriteria ' Find next employee. Loop
exitAddBranch: Exit Sub
'--------------------------Error Trapping -------------------------- errAddBranch: MsgBox "Can't add child: " & Err.Description, vbCritical, "AddBranch Error:" Resume exitAddBranch End Sub
I use Access 2010 on Windows 7 64b to create a form with a Treeview control. However, this control is missing from the list of controls activix. How can I add?
I downloaded a sample treeview application I have modified most of its to suit my need, except one thing. I want link parent/child node the main form to the main form through a subform on the CategoryID.
The following is the original code where when a child not is clicked only pops up a "linked" msgbox. I need to modify the part of the code on the Select Case "C" in red:
Code: '---------------------------- Sub DisplayForm(i As Integer) '---------------------------- ' for this Treeview I do not want a double-click on a parent node ' to open the applicable Category form, but pressing the shift key ' should open the marriage form applicable to the parent node. Shift ' or double-click on a child node should open the applicable ' offence form.
Dim strKey As String Dim strTag As String Dim strFilter As String
Still fighting to understand a darn thing about treeviews. What I was hoping to do was create a kind of knowledge base that I could integrate into a larger database I'm using. I wanted for each entry to have a category, short description and then longer details. Then for the treeview to display each item grouped by category. So in the treeview, you'd click on Category 1 and it would display every knoweldge base item that is in category 1. Click on any of those nodes and have the subform change to display that knowledge base item.
I have NO idea how to design the treeview to do this. But have laid out the database to do just about everything else.
I've been trying to use TreeView control to display my computer's directories and folders just like Windows Explorer does.
Thanks to Popeye for reposting all the Treeview samples (samples posted before the site was hacked). Most or all of these samples, TreeView is used to display data out of tables. Mr. Ghuson posted a great example for browsing directory but it pops up a separate windows for browsing.
Now I'd like to somehow combine the two into one; browsing thru directories and folders using TreeView Control. Yes that I can browse and save all paths and directories to different tables and add them to the TreeView control but I'm trying to stay away from saving data to tables first.
Can this be accomplished? Can Windows Explorer be somehow embeded on an Access form or called? Any ideas, experts out there?
I have a treeview control which is based on a table.
For some reason it won't fill properly, it doesn't add the nodes under the correct parent. If someone could look at the attached file and help me out I'd appreciate it.
This is the first time I've tried to work with a treeview control and it's very challenging. I've developed the branch building code in the form's module to a point where I'm confused on how to proceed. I've attached the database and a "readme" file to this posting. I hope someone can help me.
I need a help/pointer converting this cascading list boxes into treeview control. Please help. All the data I need to construct a treeview is already at category_info table, but unable to show it attrib_cde (parent), Stage (child of parent), and ID (child of Stage). Any help or a quick example is highly appreciated.
I'm venturing into the abyss of treeviews and have read many threads on this subject. I have two questions to ask regarding the attached sample db, if anyone can help me please.
1) How can I adapt the existing code and create subnodes (or sub child nodes). For example, how can I create a sub-node of OPEN FORM2? 2) What is the syntax for an ONCLICK event, i.e. by clicking on OPEN FORM2 I want it to open FORM2?
I'm really new at VB. But I'm learning. I'm also learning to work around access too. What I'm trying to do is have a Form with a TreeViewCtl that acts as a menu for other forms. I'd like to have the TreeViewCtl open those forms in a subform so there is always just one form open at all times. This way my "clients" don't get lost in the forms. Believe me, they get lost easily...
I already posted a question like this here: http://www.access-programmers.co.uk/forums/showthread.php?t=80756 But I'm not sure if this is a VB question (TreeViewCtl) or a Forums question... A sample of what I'm trying to do is available at the link. My TreeViewCtl works fine, but the forms open in seperate forms. Sorry for the dbl-post.
Does anyone have any ideas? I've been searching google for 2 weeks without any answers.
I'm trying to create a form that is reading filenames from a certain folder on my computer. The filenames have some prefixes - 'tu' , 'tc' , 'bf' , 'tf' and 'act'. each filename that is read is being displayed (without it's prefix) in a list and has another attribute (type) that the prefix is inserted into it.
Does someone know how to start this kind of application ?
I have an application that uses a treeview to load a product hierarchy (n-number of levels deep) for an electroinic system based on a querydef that provides the following data:
Parent | Child | ChildName
I am able to load the treeview control using recursive lookups without an issue. Difficulty arises when a Child assy points to more than one Parent (happens in about 20% of the Systems sampled so far). This is a legitimate condition. Example: CircuitCardA (Child) is used in more than one Box (Parent) in an electronic system (Recordset).
I have played with a couple strategies of concatenating the ParentName with the ChildName, but this breaks the referential integrity of the tree.
Can anyone suggest strategies to deal with legitimate non-unique keys in a Treeview?
Am looking to do a treeview type of search to hyperlink to client file/folders on my network. This way I can hide the main file source location in the network and files can just be accessible via Access program search.
So far I found this link [URL] and the 3rd bottom option seems to be the most promising but I cant seem to figure how to accomplish the hyperlinks.
I have managed to populate a treeview with some menu items I required and it looks great but I now need to get it to do something. How do I get a tree view value (selection) to act as a variable in routine. e.g. if my tree look like this.
Menu ¦ - Compaint management I I----My compaints
When I "double click" on My Complaints I want it to a open a specific form. One I know how to do one action I should be able to figure the rest out for myself.
I am using Windows 8.1 64 bit system. Into attached access file (OfferStudy.accdb) ,trying to load an activeX TreeView control by defining into a form module. First, I created an empty form and activeX Treeview control.When I define tv variable As TreeView as created in application, it is changing as Dim tv As treeView instead of TreeView. After my code is completed,an error message ("user-defined type not defined") is returning as shown in attached (DebugError.png)file.
I suppose that there is some conflict on creating activeX control on my Access 2013 application.
I have a tree-view object that is filled with a specific folder list, when a command button is pressed I would like too expand to a specific node based on a variable/foldername.
How to achieve this? My knowledge of tree-view is limited and I am still learning VBA.
I have been looking into populating a tree-view with folders and files, and have found some great examples for doing this, How ever...I cannot seem to work out how to show files/pictures in a form based on the click event of the tree-view.
I have managed to do an onclick event for the files in the tree-view, but I cannot seem to get the onclick event for folders in a tree-view.
Here is an example which I am working on at the moment, but get the error Object variable Or with block variable not set.
Code: Private Sub tvw_Click() Dim tClient As String Dim tParent As Scripting.folder Dim fd As Scripting.folder Dim fNode As MSComctlLib.Node
I'd like to expand me tree view automatically when a node matches a string variable from a table. In other words, when a node in a tree matches the given name (variable), the tree will expand all the way down to that name. I guess I need to use "For each node" and when the node and variable match, the tree structure will show up.
I have come up with something like this:
Code: For Each nd In Me.tree.Nodes If nd = level1 Then nd.Child.EnsureVisible Exit For End If Next nd Me.tree.SetFocus
But this only shows the first level of my tree ( btw. I have a 3 level tree). I get lost inside the FOR when I want to make use of another two variables - level2 and level 3
I added a new field to one of my tables and query, but when I try to add a control for that field into my form it is not recognising it and the field isn't appearing in the sources for the form, even though the table is sourced to the form? Or am I going to have to do the usual and redo the entire form because I made a minor adjustment?
I have a form with a tab control, inside the tab control I placed an ActiveX control (Microsoft Web Browser). These are at the bottom of the form.
Everything displays fine if the entire form fit on the screen but if the form is too long and I scroll down the browser control is getting obscured by the tab control and getting chopped off (the contents are covered). It is as if the browser control is staying in space where it was and moving behind the tab control as I scroll.
This problem does not occur if I place the browser control directly on the form. Also I note that the browser control is sitting correctly within the tab control.
I have been through all the settings and properties of both controls and haven't been able to fix it. I searched all over the web but no one has previously stumbled across this one by the look of it.
I have table that I had to add a new field to which we update with a form. I tried to add a control for the new field but the field does not show up in the list for the control source. I am trying to add a list box to the form with a blank and 5 options.
I have attached screen shots of the table design and the form. The table has the field in datasheet view and I have manually entered a few entries in it but it still will not show in the control source for the form control. The top section of the form is where we enter and select the data for the new records. The bottom section (circled in red) autofills the matching record, from separate tables, for updating with the new entries.
I have added form controls for modified fields in the past so I am confused about why this is happening.
OK. I have searched and searched and every thread dances around similar situations but none seem to address this particular one. I am trying to make a control on a sub form visible/not visible depending on the condition of a control on a main form. The catch is that the control I'm trying to change the state of is on a subform located in a tab control. I've tried a thousand combinations and none seem to work. How do I reference the control on the subform in a tab control?
Main Form: frmMemberMain Tab Control: TabCtl12 Tab Control Page: 2 Subform: frmChildren Control on subform: txtRelationship
Can someone please help before my brain explodes!! Thanks! :eek:
I have reviewed the posts for 'Control Validation' and dowloaded the sample database kindly posted by ansentry.
In the PaymentAmount example, a name has to be entered in the first control before an amount is enterered in the second control. If the controls and tab order are reversed, the validation doesn't work.
I have a form where the 1st Control needs validating before moving on. The code below doesn't work.
Private Sub Form_BeforeUpdate(Cancel As Integer) If IsNull(Me.Employee_No) Then MsgBox "Employee No Required", vbCritical, "Data required " Cancel = True Me.Employee_No.SetFocus Exit Sub End If