Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Generating the Bible Books and Chapters in a treeview control

Posted on 2004-09-03
2
Medium Priority
?
480 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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…
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…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

722 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