Error when using Treeview & TabControl together

G

Guest

I have a form that contains a Combobox and a TabControl with two tabs on it.
The combobox is used to select which record to populate the form with.

Tab A contains some general textboxes with RecordSources, and Tab B contains
a Treeview Control that is populated when the user changes the selected
record with the combo box. When I had all of this stuff on the same form I
didn't have any problems changing records, however when I had the TreeView on
a seperate tab, it sometimes produces the following error:

---
Run-time error '-2147417848 (80010108)':

Method 'Add' of Inodes failed.
---

And it proceeds to highlight the following code line in my populate method:

tvwControl.Nodes.Add , , "_" & rs(0), rs(1)

This is the very first item that is added to the TreeView control, the
control has just been cleared, rs(0) contains the number 1 and rs(1) contains
the correct text to be added to the tvwControl. The thing that makes this
really weird is, when I click "Debug", and then hit the play button, the list
populates fine half of the time, and the other half of the time the list has
one or two nodes with garbage text (random ascii characters, or all question
marks).

Another weird thing is, this error only happens when I switch from Tab A, to
Tab B, and then back to Tab A before changing the value in the combo box. If
I'm already on Tab A and I've never been to Tab B it populates fine
(including on form_load).

This is all very confusing
 
G

Guest

I was able to re-create this error easily, try the following (save all work
and exit access before doing this):

Open a blank access database, create a new form, place a tabcontrol on it.
On the first tab place nothing, on the second tab place a treeview control
(by using the "More Controls" button, and clicking Microsoft TreeView Control
6.0, and drawing it on the page). Name it tvwTestControl for the purpose of
this excercise. Add a command button to the form outside of the Tab Control.
Right click on the command button that you just added and click "Code
Builder", and type in the following code:

tvwTestControl.Nodes.Clear
tvwTestControl.Nodes.Add , , "ABCD","This is a test node"

Open the form object, click the command button and observe that it works
fine. Click on the second tab, observe the added node. Click back onto the
first tab, and then click the command button again.

The program will now generate an error... and access may even crash soon
afterwards.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top