ClaraBarton
Registered User.
- Local time
 - Yesterday, 18:29
 
- Joined
 - Oct 14, 2019
 
- Messages
 - 754
 
I've messed and messed with this.
When I debug, the intChapter is 0 but it still jumps to the 2nd case and then throws an error that the element isn't found. It isn't found because the node belongs on a book (case 1) and not a chapter (case 2).
I know you always find my logic errors... What am I doing wrong here?
	
	
	
		
 When I debug, the intChapter is 0 but it still jumps to the 2nd case and then throws an error that the element isn't found. It isn't found because the node belongs on a book (case 1) and not a chapter (case 2).
I know you always find my logic errors... What am I doing wrong here?
		Code:
	
	
	 strSql = "SELECT t_recipe.cookbookid, t_recipe.recipeid, " & _
        "t_recipe.recipename, t_recipe.cookbookchapterid " & _
        "FROM t_recipe " & _
        "ORDER BY t_recipe.cookbookchapterid"
    Set rsRecipes = db.OpenRecordset(strSql)
        Dim intChapter As Integer
        intChapter = Nz(rsRecipes!cookbookchapterid, 0)
        
        Do Until rsRecipes.EOF
            Select Case intChapter
                Case intChapter = 0
                    Me.tvCookbooks.Nodes.Add _
                        Relative:="CB" & rsRecipes!cookbookid, _
                        Relationship:=tvwChild, _
                        key:="R" & rsRecipes!recipeid, _
                        Text:=rsRecipes!recipename
                
                Case intChapter <> 0
                     Me.tvCookbooks.Nodes.Add _
                        Relative:="CH" & rsRecipes!cookbookchapterid, _
                        Relationship:=tvwChild, _
                        key:="R" & rsRecipes!recipeid, _
                        Text:=rsRecipes!recipename
            End Select
           rsRecipes.MoveNext
       Loop