Solved

Generating the Bible Books and Chapters in a treeview control

Posted on 2004-09-03
2
472 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

760 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

18 Experts available now in Live!

Get 1:1 Help Now