473,385 Members | 1,796 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Tree Code (Element not found error)

Hi, I used your sample to get my TreeView Control to work with a parent child table (Modules/Devices). If fills in the parents just find but tells me an element is not found when adding the children, Do I need to set a property or something? My code is below. I am setting the tree on Form Open
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open(Cancel As Integer)
  2. Dim MyRS As DAO.Recordset
  3. Dim MyRSChild As DAO.Recordset
  4. Dim strSQL As String
  5.  
  6. Me![TreeView1].LineStyle = 1    'Root lines
  7. Me![TreeView1].Style = 7        'TreelinesPlusMinusPictureText
  8.  
  9. Set MyDB = CurrentDb()
  10. Set MyRS = MyDB.OpenRecordset("tblModulHeader", dbOpenDynaset)
  11.  
  12. '1-Relative, tvwChild-Relationship, "g"-Key, "George"-Text "ROOT Node"
  13. Set nodX = TreeView1.Nodes.Add(, , , "MODULES AND RELATED DEVICES")
  14. 'Populate Customer Nodes
  15. Do While Not MyRS.EOF
  16. Set nodX = TreeView1.Nodes.Add(1, tvwChild, "MODULE" & MyRS![Module_ID], MyRS![Module_DESC])
  17.     nodX.EnsureVisible
  18.     MyRS.MoveNext
  19. Loop
  20.  
  21. strSQL = "Select * From tblModuleDetail"
  22. Set MyRSChild = MyDB.OpenRecordset(strSQL, dbOpenSnapshot)
  23.  
  24. 'Populate Module details
  25. Do While Not MyRSChild.EOF
  26.    Set nodX = TreeView1.Nodes.Add("MOD ID" & MyRSChild![Module_ID], tvwChild, "Mat_ID" & MyRSChild![Mat_ID], "Material Description" & CStr(MyRSChild![Material_Desc]))
  27.     MyRSChild.MoveNext
  28. Loop
  29.  
  30. 'Accentuate the Root by making Text Bold
  31. TreeView1.Nodes(1).ForeColor = QBColor(4)
  32.  
  33. 'Select the Root
  34.  TreeView1.Nodes(1).Selected = True
  35.  Me!TreeView1.SetFocus
  36.  SendKeys "^{HOME}"
  37.  MyRSChild.Close
  38.  MyRS.Close
  39.  Set MyRSChild = Nothing
  40.  Set MyRS = Nothing
  41.  
  42. End Sub
May 3 '16 #1
2 1547
zmbd
5,501 Expert Mod 4TB
Before get too deep here, have you taken a look at:
TheSmileyCoder Treeview Article(s)

You might want to visit his Youtube channel for the entire series.
May 3 '16 #2
jforbes
1,107 Expert 1GB
I've used TheSmileyCoder's examples and they are great. You might want to just start with his code as your base.


From Add Method (Nodes Collection) the First parameter is defined as:
Relative Optional. The index number or key of a pre-existing Node object.
Based on that, I think what you are running into is that your first parameter needs to resolve to a valid index of an existing node or an actual Parent node passed along to the method:
Expand|Select|Wrap|Line Numbers
  1. Set nodX = TreeView1.Nodes.Add("MOD ID" & MyRSChild![Module_ID], tvwChild, "Mat_ID" & MyRSChild![Mat_ID], "Material Description" & CStr(MyRSChild![Material_Desc]))


Lastly, this is a quick and dirty example of adding some Child nodes:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2.     Dim iCount As Integer
  3.     Dim oBinderNode As MSComctlLib.Node
  4.     Dim oAttachmentsNode As MSComctlLib.Node
  5.  
  6.     Me.TreeView0.Nodes.Clear
  7.     ' Create Parent
  8.     Set oBinderNode = Me.TreeView0.Nodes.Add(, , "Binder:Root", "Root")
  9.     'Create Children
  10.     For iCount = 1 To 10
  11.        Set oAttachmentsNode = Me.TreeView0.Nodes.Add(oBinderNode, MSComctlLib.TreeRelationshipConstants.tvwChild, "Attachment:" & iCount, "Attachment #" & iCount)
  12.     Next iCount
  13. End Sub
May 4 '16 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: TimS | last post by:
I am getting a baffling File not found error (0x800A0035). I am writing asp on a windows 2000 server. I build a path and filename from several fields in a jet database using SQL commands, like...
1
by: Ciaran Byrne | last post by:
I would like to use the XML API supplied by ClickaTell (http://www.clickatell.com) in my code. I have a simple XML file, which I've test in their online demo and it works fine. I now want to...
19
by: MLH | last post by:
I call the following Sub and Function in frmLaunch's OnOpen event code. I keep getting Property Not Found error for the AllowBypassKey setting. Failure point is line #30 in the Function (not the...
15
by: warlord | last post by:
I have a windows client app that is trying to download a file from a web server but I always get the following error when I call the GetResponse method of the Request object. The remote server...
5
by: jiangyh | last post by:
hi there: I use following source to fire outlook express,but I have a file not found error. System.ComponentModel.Win32Exception: File not found ...
0
by: vcuser | last post by:
All, Can someone please let me know if you have come across this error in VC 7.1 when trying to implement an interface using the "Implement Interface wizard"? If so, can you please let me know...
6
by: RML | last post by:
Hi, I have a VS2005 VC++ application which no longer allows me to add a Variable or Function to a class in the project. I attempt to add a new (public) Variable called Temp123, and get this...
8
by: priya0123 | last post by:
:confused: Hi, I have created a treeview control in asp.net 1.1 and worked perfectly fine on my development box. Now I have uploaded the pages to my sandbox(test box), everything is fine there (...
1
by: C.Joseph Drayton | last post by:
Hi All, I am not sure if this is a JavaScript or PHP error. Basically what is happening, is that I have an HTML page with the following JavaScript. As you can see makeRequest() calls a PHP...
5
by: stmfc | last post by:
i dont know why pl/sql block below returns no data found error. do you have any idea about it? declare c1 varchar2(80); c2 varchar2(80); begin execute immediate 'select col2 from table1 where...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.