Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Treeview problem 1

Status
Not open for further replies.

irishjoe

Programmer
Aug 5, 2002
76
AU
Ok, this is going to seem like a stupid problem but bare with me…

I have a 2002/3 database with a treeview on the left which filters all the forms to the right. 90% of the time, it works great. The other 10% is something else. It seems not to register the clicking in the tree and even if I stick debug statements right at the start, it doesn’t print anything in the immediate window. Same goes for putting a breakpoint in, it doesn’t get that far.

I have tried importing the data, queries, forms and code into a new database but it does it there too. (10% of the time.)

All the computers that are running it are service packed and up to date. Using access 2003 to read the database.

The weird thing is, it seems to fix itself somehow sometimes. I am unsure how this is happening as I can’t get it to do it when I want it to.

Can anyone suggest any other avenues to find out what’s going wrong? I’ve got no idea why it would stop registering the mouse clicks on the tree view.
 
1. When you say fix, do you have to leave the form and come back in or does it just start working again?
2. Could the database be processing? Could a "do events" in your code help?
3. The treeview control is buggy, but I have never seen that one. Check out the MSDN, there are a lot of known bugs.
4. Can you post your node click event?
5. Any chance you are using a custom class and losing the reference to the class?
 
When I mean fix itself, it would suddenly start recognising the clicks out of the blue. Sometimes moving it from the server to the desktop would prompt it or someone else accessing it and then you access it and it would start working.

I thought it might have something to do with the icons so I took them out and found out something interesting. When you go into design view then go into form view, the tree would work fine. But if you go straight into form view, it wouldn’t.

I don’t think the database is running anything, the VBA screen usually flickers when its running something when you have a form open and doing something.

I have stripped all the code of the onclick so it just looks something like this…

Private Sub axTreeView_NodeClick(ByVal node As Object)
Debug.print “Clicked ***”
End Sub

I don’t know what a custom class would be, but it could be hidden in there somewhere, I didn’t create the database, I’m just making changes to it. Will have a look into it.

Thanks for the quick reply. This has been bugging me for ages now and the client isn’t too impressed when it keeps breaking…
 
I do not have any good idea without seeing it. But maybe you can do a work-around, based on your observation. Open it in design view, but hidden then in form view

DoCmd.OpenForm "frmTree", acDesign, , , , acHidden
DoCmd.OpenForm "frmTree"

It is a long shot.
 
I tried something like that before but didn't know where to put it. I tried creating a form with that code on the onload part then I would hide the first form. But it didn't work.

I did just get one bit working tho... Yes, macros are evil and should be steered clear off but I created one to open the main menu in design view then on the line below, I opened the same form but in form view. So its doing the same as you said but in a macro instead of code.

It seems to be working but I need to test it on some other machines and some other copies of the database.

Thanks for your help!
 
I normally have a switchboard that allows me to open forms and reports. So I would make a procedure

public sub openTree()
DoCmd.OpenForm "frmTree", acDesign, , , , acHidden
DoCmd.OpenForm "frmTree"
end sub

and from my switchboard I would click a button and it would call "openTree".

If this works I have no reason why.
 
It did work.... until I made a MDE to send to the client.

I made a macro to open the main menu in design view then open in form view and called it Autoexec so it would automatically run.
But the MDE came back and said that action wasn't allowed in an MDE database.

I've never used a switchboard, is it just a main menu that access automatically creates?
 
Got rid of the macro and made an empty form that would auto load and load the main menu and then close itself. No go there either. Says I'm not allowed to do that in an MDE. Works fine in an MDB.


Code:
Private Sub Form_Load()
    openTree
    Form_frmStarter.SetFocus
    DoCmd.Close
End Sub


Public Sub openTree()
  DoCmd.OpenForm "frmTree", acDesign, , , , acHidden
  DoCmd.OpenForm "frmTree"
End Sub
 
acDesign
Forbidden in an MDE

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
What version of the Treeview control do you have? I noticed that SP3 VB6.0 mentions fixing a problem where the tree view control stops functioning after tree view navigation
 
How do I find what version I have?
My access version is 11.8166.8221 SP3
 
Look in your references while in the vb editor
The current version is
Microsoft Common Controls Version 6.0 (SP6)

There is an older 5.0 set of common controls.
 
Sorry. I am out of ideas. I googled and could not find any discussion on "node click not firing". My only thought is why does it work if you go to design view first? This may have something to do with compiling the code. It seems if you run it uncompiled it works. My last try would be to rebuild the form.
 
I've deleted the tree, added a new one and re-doing how the tree filters the forms. It could be something in there that is messing it up. I have a couple of other databases that use treeviews and not had any problems like that with them so no harm in re-writing the code to do it the way I understand.

Thanks again for the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top