Solved

Generating the Bible Books and Chapters in a treeview control

Posted on 2004-09-03
2
475 Views
Last Modified: 2012-06-27
I have the entire bible saved in an access database by verse.  There are 31,150 total verses stored in records. The database is designed as follows:
Table = "Bible"
Book_Name = "Text format"
Chapter = "Integer format"
Verse = "Integer format"

How can I programmitcally generate text in a treeview control with Book_Name displayed as a Node and the Chapters displayed as Subnodes.  Heres an attempt of what I'm looking for:

Genesis
     |___1
     |___2
     |___3
     |___4
Exodus
     |___1
     |___2
     |___3
     |___4

Etc.


   
0
Comment
Question by:mcdonald_g
2 Comments
 
LVL 11

Accepted Solution

by:
bingie earned 350 total points
ID: 11978306
Each book number will require its own key to be able to be related in the treeview. This key cannot be numeric, but alpha-numeric.

For example,  

  Genesis (Key G1)
  Exodus (Key E1)
  Mark (Key M1)

Each chapter will then require this key to be related in the tv.
 
  Genesis Chapter 1 (Related to G1)  key = vG1
  Genesis Chapter 2 (Related to G1)  key = vG2
  ....

Each verse will then need to be related to the above

  Genesis Verse 1 (Related to vG1)
  Genesis Verse 2 (Related to vG2)


Thus, your database will need an extra field to hold the key. In my database (which does the same) i have a table with the parent keys - which is read to create the parent nodes, then a table to hold the data with a field for the key - to reference the parent. I extract the data from the parent key table first, and assign the key - the loop through the data table and add the items one key at a time.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

The syntac to add items to the tree view is as follows:

Parent Node
     - Child 1
           - Child 2

Parent Node  tv.Nodes.Add , , parentKey, description
Child 1 Node    tv.Nodes.Add parentKey, tvwChild, childKey, description
Child 2 Node    tv.Nodes.Add ChildKey, tvwChild, child2Key, description

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Add a treeview control to your form and name it tv. Paste the below to see a sample of what i am talking about:

Private Sub Form_Load()

'Add parent nodes
tv.Nodes.Add , , "g1", "Genesis"
tv.Nodes.Add , , "e1", "Exdoses"
tv.Nodes.Add , , "m1", "Mark"

'Add child items
tv.Nodes.Add "g1", tvwChild, "vg1", "Chapter 1"
tv.Nodes.Add "g1", tvwChild, "vg2", "Chapter 2"
tv.Nodes.Add "e1", tvwChild, "ve1", "Chapter 1"
tv.Nodes.Add "e1", tvwChild, "ve2", "Chapter 2"
tv.Nodes.Add "m1", tvwChild, "vm1", "Chapter 1"
tv.Nodes.Add "m1", tvwChild, "vm2", "Chapter 2"

'Add child items
tv.Nodes.Add "vg1", tvwChild, , "verse 1"
tv.Nodes.Add "vg2", tvwChild, , "verse 2"
tv.Nodes.Add "ve1", tvwChild, , "verse 1"
tv.Nodes.Add "ve2", tvwChild, , "verse 2"
tv.Nodes.Add "vm1", tvwChild, , "verse 1"
tv.Nodes.Add "vm2", tvwChild, , "verse 2"

End Sub
0
 

Author Comment

by:mcdonald_g
ID: 11978500
This is exactly the code I needed bingie!  Do you know how to add pictures to the treeview control? Also, how do I navigate to a particular recordset when the user clicks on a chapter or verse?
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now