MS Access Crashes on TreeView.Nodes.Clear

I found a specific situation where MS Access always crashes to desktop.  Here are the ingredients:

  1. A bound Form with a Microsoft TreeView Control, version 6.0.
  2. Form’s “Allow Additions” property set to “No”
  3. TreeView populated using the Form_Current() event.
  4. Prior to populating the TreeView, calling .Nodes.Clear on the TreeView object.
  5. To set up the crash, filter the form to an empty recordset.
  6. Click on the Home ribbon and the Toggle Filter button.

Download Testcase File: treeview-testcase.accdb

Workaround

In the Form_Current() event, add a DoEvents command immediately before Nodes.Clear.

Set MyTree = Me.TreeView0.Object
DoEvents
MyTree.Nodes.Clear

Leave a Reply

Your email address will not be published. Required fields are marked *