Results 1 to 5 of 5
  1. #1
    kent is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    May 2019
    Posts
    38

    Bolding Treeview Node Not Working


    I've used the built-in Treeview functionality in my database, but on a new form I'm having an issue where the Treeview is not responding to code to bold certain nodes. My other treeviews (running different but similar code) don't have a an issue displaying bolded nodes. Here's the subroutine I use to generate the treeview:

    Code:
    Public Sub loadTVArticlesGroup_Ext(tv As TreeView, ArticleGroup As Long)
    
    tv.Nodes.Clear
    
    Dim nodx As MSComctlLib.Node
    Dim nody As MSComctlLib.Node
    
    Dim ArticleSourceSQL As String
    ArticleSourceSQL = " SELECT REF_ArticleSource.ArticleSourceID, REF_ArticleSource.ArticleSourceName " _
        & " FROM REF_ArticleSource INNER JOIN MAIN_Articles ON REF_ArticleSource.ArticleSourceID = MAIN_Articles.ArticleSource " _
        & " WHERE MAIN_Articles.ArticleGroup = " & ArticleGroup _
        & " GROUP BY REF_ArticleSource.ArticleSourceID, REF_ArticleSource.ArticleSourceName " _
        & " ORDER BY REF_ArticleSource.ArticleSourceName;"
    
    
    Dim rsArticleSource As DAO.Recordset
    Set rsArticleSource = CurrentDb.OpenRecordset(ArticleSourceSQL, dbOpenDynaset, dbReadOnly)
    
    
    Dim ArticleItemSQL As String
    ArticleItemSQL = "SELECT MAIN_Articles.ArticleID, REF_ArticleSource.ArticleSourceID, REF_ArticleSource.ArticleSourceName, MAIN_Articles.Title, MAIN_Articles.CreateDate " _
        & " FROM REF_ArticleSource INNER JOIN MAIN_Articles ON REF_ArticleSource.ArticleSourceID = MAIN_Articles.ArticleSource " _
        & " WHERE MAIN_Articles.ArticleGroup = " & ArticleGroup _
        & " ORDER BY REF_ArticleSource.ArticleSourceName, MAIN_Articles.CreateDate, MAIN_Articles.Title;"
    
    
    Dim rsArticleItem As DAO.Recordset
    Set rsArticleItem = CurrentDb.OpenRecordset(ArticleItemSQL, dbOpenDynaset, dbReadOnly)
    
    If Not rsArticleSource.EOF Then
    
        rsArticleSource.MoveFirst
        
        Do While Not rsArticleSource.EOF
        
            Set nodx = tv.Nodes.Add(, , "sID" & rsArticleSource!ArticleSourceID, rsArticleSource!ArticleSourceName)
            nodx.Bold = True     'NOT WORKING?
            nodx.ForeColor = vbBlue
            nodx.Expanded = True
    
                rsArticleItem.FindFirst "ArticleSourceID = " & rsArticleSource!ArticleSourceID
                
                Do While Not rsArticleItem.NoMatch
                
                    Set nody = tv.Nodes.Add(nodx, tvwChild, "aID" & rsArticleItem!ArticleID, rsArticleItem!Title & " (" & rsArticleItem!CreateDate & ")")
                    nody.Expanded = True
                rsArticleItem.FindNext "ArticleSourceID = " & rsArticleSource!ArticleSourceID
        
                Loop
        
            rsArticleSource.MoveNext
        Loop
        
        'bring focus to top of treeview
        tv.Nodes(1).Selected = True
        tv.Nodes(1).Selected = False
    
    End If
    
    'cleanup
    If Not rsArticleSource Is Nothing Then
        rsArticleSource.Close
        Set rsArticleSource = Nothing
    End If
    
    
    If Not rsArticleItem Is Nothing Then
        rsArticleItem.Close
        Set rsArticleItem = Nothing
    End If
    
    End Sub
    Here's my treeview settings for reference:
    Click image for larger version. 

Name:	MS Access Treeview Issue.jpg 
Views:	13 
Size:	57.1 KB 
ID:	51797

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    By "not responding", you mean the code executes but text is not bolded? I get the same behavior when trying to set bold in loop adding nodes. However, if I set it in Open event that establishes treeview control it works and applies to all nodes.

    tv.Font.Bold = True

    What is your working code that sets bold?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    kent is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    May 2019
    Posts
    38
    The code executes but the relevant nodes are not bolded. I tried putting the subroutine in Form_Open and the code works as expected. I have a subform on the same form, and using the On Current event in the subform has interfered with other MS Access flow, and that might be the culprit here.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    I took another look at my code to bold in subroutine loop and I do see only the top node is bolded. I will have to explore this some more.

    Interesting, my code sets each node ForeColor but when I try to set Bold in the same location, doesn't work. Oh well not something I really need. I hope you get resolution.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    kent is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    May 2019
    Posts
    38
    I figured out how to fix it in my case, I had to fire the subroutine to update the treeview last after everything else, including some subreport filtering. Then the nodes are bolded as expected.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Access: Find a treeview Node
    By peperoncino in forum Access
    Replies: 6
    Last Post: 07-13-2022, 02:30 PM
  2. Replies: 4
    Last Post: 10-04-2021, 06:24 AM
  3. Replies: 7
    Last Post: 11-20-2014, 11:21 AM
  4. Bolding text
    By newtoAccess in forum Access
    Replies: 6
    Last Post: 11-13-2010, 01:29 PM
  5. Bolding a record in a field that is the max
    By salisbut in forum Access
    Replies: 3
    Last Post: 08-17-2010, 09:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums