Solved

Generating the Bible Books and Chapters in a treeview control

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

Suggested Solutions

Title # Comments Views Activity
Macro: print each sheet to pdf using ExportAsFixedFormat 11 62
Can we place a tooltip on the actual vb6 form 5 50
Problem to line 23 73
Collapse and expand table in Word 2010 2 91
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

740 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