Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Feb 2003
    Location
    Hartford, Connecticut, USA
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Treeview - recursive (Access 97)

    <P ID="edit" class=small>(Edited by charlotte on 14-Feb-03 19:18. to activate link)</P>I am using the sample code from Microsoft Knowledge Base Article - 167309 to build a treeview. Microsoft's sample code terminates without building the treeview.

    My table has three fields.
    fldCondition, text, Primary Key field, indexed , no duplicates
    fldParent, text
    fldChild, text


    The field "fldCondition" is made up of a concatenation of the parent and the child.

    For example the first record has a null value for the parent. I did this because in debug mode I could see that the code seemed to be looking for a record that had no parent as a starting point for building the treeview.

    Here are the first 18 records to show the data being used.

    fldCondition ______________fldParent___fldChild
    EEEEEEEEEEEEEEEEEEEE __________ EEEEEEEEE
    EEEEEEEEEXEEEEEEEEXO EEEEEEEEE EEEEEEEEX
    EEEEEEEEEXEEEEEEEXEO EEEEEEEEE EEEEEEEXE
    EEEEEEEEEXEEEEEEXEEO EEEEEEEEE EEEEEEXEE
    EEEEEEEEEXEEEEEXEEEO EEEEEEEEE EEEEEXEEE
    EEEEEEEEEXEEEEXEEEEO EEEEEEEEE EEEEXEEEE
    EEEEEEEEEXEEEXEEEEEO EEEEEEEEE EEEXEEEEE
    EEEEEEEEEXEEXEEEEEEO EEEEEEEEE EEXEEEEEE
    EEEEEEEEEXEXEEEEEEEO EEEEEEEEE EXEEEEEEE
    EEEEEEEEEXXEEEEEEEEO EEEEEEEEE XEEEEEEEE
    EEEEEEEEXOEEEEEEEOXX EEEEEEEEX EEEEEEEOX
    EEEEEEEEXOEEEEEEOEXX EEEEEEEEX EEEEEEOEX
    EEEEEEEEXOEEEEEOEEXX EEEEEEEEX EEEEEOEEX
    EEEEEEEEXOEEEEOEEEXX EEEEEEEEX EEEEOEEEX
    EEEEEEEEXOEEEOEEEEXX EEEEEEEEX EEEOEEEEX
    EEEEEEEEXOEEOEEEEEXX EEEEEEEEX EEOEEEEEX
    EEEEEEEEXOEOEEEEEEXX EEEEEEEEX EOEEEEEEX
    EEEEEEEEXOOEEEEEEEXX EEEEEEEEX OEEEEEEEX

    Side note:
    For those wondering about the date, it is the kid's game of Tic-Tac-Toe.
    This is a training lesson I am writting on finding and mapping all possible outcomes.
    In fldConditions positions 1-9 are the starting positions of all nine squares on the board where "E" is empty, "X" and "O" are the turns played; position 10 is whos turn it is to play next. Position 11-18 represent a move that is possible (ie the child) given the parent; position 19 is who gets to play after this "child" move is carried out. Showing that almost all Child can become Parents to some other move. And Position 20 show if the move ends the game by a stalemate "S" or an win by either "X" or "O".


    Implementation:
    I have followed the instruction in the MS article about inserting the ActiveX object and naming it, style set to 6, etc.

    Using the sample code I have made the following replacements
    Const strTableQueryName = "Employees" became "tblData"
    strPointerField:="ReportsTo" became "fldParent"
    strIDField:="EmployeeID" became "fldCondition"
    strTextField:="LastName" became "fldChild"

    When the code is run only orignal parent "EEEEEEEEE" is shown as a node, with no children.
    This where I get stuck. Any help would be great.

    Thanks
    Tom

    P.S I saw that Charlotte (Moderator WMVP) had previously answers a treeview question in post 41863.

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Treeview - recursive (Access 97)

    Well, I just pasted the MS sample code into an Access 2000 form, selected a treeview control from the toolbox, made sure the control was named xTree and and ran the form. It worked just fine, although it only displayed the top node until you double clicked it. Have you tried creating the exact same treeview that they describe using the Employees table from Northwind? If you can get that working, then you will know you have the basic functionality. Then when you change the table, fields, etc., you should be able to see exactly what you want and be able to tweat it successfully.
    Charlotte

  3. #3
    New Lounger
    Join Date
    Feb 2003
    Location
    Hartford, Connecticut, USA
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Treeview - recursive (Access 97)

    Thanks for the fast reply Charlotte.

    Yes, before trying the sample code in my DB I tried it in a copy of the Northwind DB and it worked just fine.

    However, when I put the code in my DB, following the prescribed steps and re-pointing the variable as noted earlier, all I got was the "top" tier. Double clicking on it has no effect. When I step through the copied code I can see that the code terminates early, without going into error. The code simple stops evaluating records after processing my first record.

    The lines of code that terminate the code

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Treeview - recursive (Access 97)

    Then it isn't a problem with the Treeview, it's a problem with your data. You can't find a match for a Null because there is no such thing. Any record that has a Null for a parent, should be changed to have something else, maybe a zero or minus 1, anything except Null.
    Charlotte

  5. #5
    New Lounger
    Join Date
    Feb 2003
    Location
    Hartford, Connecticut, USA
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Treeview - recursive (Access 97)

    I found the answer.

    Your insight about the data got me looking in the right direction.

    The code most definitely does indeed need the data to have a null value so as to establish the

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •