Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Generating the Bible Books and Chapters in a treeview control

Posted on 2004-09-03
2
Medium Priority
?
482 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 1400 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

886 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