Hierarchical Data, Recursion, Tree-View, and a another Great Custom Class (1 Viewer)

MajP

You've got your good things, and you've got mine.
Local time
Today, 15:27
Joined
May 21, 2018
Messages
3,159
@MajP - A note for the vba code.... The folder that holds the .BMP images, can only contain records that are in the table, NO Extras. If you have extra pictures in the folder, the code errors (run-time '481', invalid picture) and the treeview won't display.
I do not think that is the problem. When you originally gave me the .bmps, I could not load any of them and had to get new .bmps. Something is corrupted in how / where you download the .bmps. I loaded my folder up with other pictures without any problem.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 15:27
Joined
May 21, 2018
Messages
3,159
I use Irfanview. Free and really good for batch conversion and renaming
You can test by going into design view. Right click on the image list and choose to edit. Should be able to load images manually. The video show you how. I got the same error trying to manually load the images.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 15:27
Joined
May 21, 2018
Messages
3,159
This is an updated class module. It has 3 updates
1) Fixes the error when you try to sort a node without an image
2) Applies highlight when moving nodes up and down.
3) Puts an optional parameter in the initialize for allowing/disallowing drag drop. Default is disallow.
Need to import the cls from in VBE.
 

Attachments

Fran Lombard

Registered User.
Local time
Today, 15:27
Joined
Mar 12, 2014
Messages
123
Update 7
Added Right click function
1) Command bar when off node
2) Command bar when over node
Duplicates a lot of the other functions

Do you have any icons you want? THey should be 32X32 pixel BMPs. With Drag and drop it will be very hard to modify the images per level of node. View attachment 79467
Any chance you can upload or send me a version of this for A2007?
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 15:27
Joined
May 21, 2018
Messages
3,159
I would think it works in 2007. What does not work? In the class and in the thread it discusses how to load the references.
 

Fran Lombard

Registered User.
Local time
Today, 15:27
Joined
Mar 12, 2014
Messages
123
Awesome job on this treeview.
I've been needing to add this functionality to my db and while I've played with trees in Vb6 some 15 years ago, I couldn't find any of the old code.

This example will save me many hours of relearning as well as give me functionality i never had.

Thank you
Fran

Ps. I assume its ok to reuse the code in my own app?
 

Fran Lombard

Registered User.
Local time
Today, 15:27
Joined
Mar 12, 2014
Messages
123
I would think it works in 2007. What does not work? In the class and in the thread it discusses how to load the references.
I got it working. It was really just the security warnings.

I did however port the table over to Mssql and updated dao to adodb and modified the findfirst & nomatch to the appropriate adodb calls. Works great.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 15:27
Joined
May 21, 2018
Messages
3,159
If you can please post the adodb version.
 

Gasman

Enthusiastic Amateur
Local time
Today, 20:27
Joined
Sep 21, 2011
Messages
5,781
Ok, I have cocked up big time here. :(

I imported that class into my Test DB
Now every time I open it it gives the error message below and I am stuck accepting the error message multiple times, so much so I have to kill Access.

I cannot delete/remove it. I have tried highlighting all the code to comment/delete it, but just get the error messages.?

How to I get rid of this please.?

1586086567048.png
 

Attachments

MajP

You've got your good things, and you've got mine.
Local time
Today, 15:27
Joined
May 21, 2018
Messages
3,159
There are some other modules in the DB that are used. There is a module to handle the command bars and I do not see that listed. I do not have it open right now to know if there are even more modules. I would import all of them from the DB.
 

Gasman

Enthusiastic Amateur
Local time
Today, 20:27
Joined
Sep 21, 2011
Messages
5,781
Well I managed to delete all the code by pressing OK many many times, but I still cannot delete that module.

I used File to import it. :oops:

I've exported what I needed, renamed it Corrupt Test and gone to backup. Lesson learnt. :)
 

Fran Lombard

Registered User.
Local time
Today, 15:27
Joined
Mar 12, 2014
Messages
123
If you can please post the adodb version.
Will do

Turns out I ported an earlier version that was much simpler - Before all the customer/orders data was in the db. Im porting this current version now and will post when ready.
 

Fran Lombard

Registered User.
Local time
Today, 15:27
Joined
Mar 12, 2014
Messages
123
Will do

Turns out I ported an earlier version that was much simpler - Before all the customer/orders data was in the db. Im porting this current version now and will post when ready.
Here is the ADODB version
There is one Folder that contains three Files in the Zip
1. TreeviewDemo.adp: MS 2007 ADP or AccessProject:
2. TreeviewDemo.bak: MSSQL 2012 Database backup File
3. qryToViews.sql: SQL file of the statements I used to convert the Access queries to Views

Not sure if I clicked every button and tested all the functionality but it seems to be working
Main Changes Needed
1. Replaced References from DAO to ADODB
2 Added a module DBFunctions which includes a set of functions for working with ADODB
3. Calls to Set mRecordSet = CurrentDb.OpenRecordset were replaced with
Set mRecordSet = DBFunctions.GetRecordSet
4. Calls to rs.FindFirst -> Replaced with rs.MoveFirst then rs.Find
5. Calls to re.NoMatch -> Replaced with rs.BOF
6. Calls to rs.FindNext -> Replaced with rs.Find
7. Bookmark Declaration changed to Variant
8. General Cleanup of table/field names - My DB is case sensitive so it barked at non-matching case

In most places I made changes I added a comment Line of ( 'FRL ) my initials so anyone could search on them.

Now I actually have to study the code so I know what I'm playing with.
Like to move from being a Plumber to a Designer

Have fun guys - Hope this helps anyone who plays with SQL in an ADP Project
 

Attachments

Fran Lombard

Registered User.
Local time
Today, 15:27
Joined
Mar 12, 2014
Messages
123
Here is an update to above Attachment - Found some areas of I had not updated - specifically the 2nd TreeForm which loads customers and orders.
Made the ports and cleaned up the query module.
 

Attachments

dgreen

Member
Local time
Today, 14:27
Joined
Sep 30, 2018
Messages
395
@MajP
Somethings not working right on the sort sequence #. The Level_ID is populating correctly but the sort order isn't. Thoughts just by looking at the output?

1586200693115.png
 

dgreen

Member
Local time
Today, 14:27
Joined
Sep 30, 2018
Messages
395
At quick glance, at the TreeView, at level 3, it appears that the sort order got reversed. I'm not sure if this is related or not.

So I'm going to resort them. Close the TreeView form.
1586202505456.png

Reopen the treeview. For the small group of 3 records that I resquenced, it's correct.

Maybe I did too many records in a single change and it got confused?

Somethings not working right on the sort sequence #
 

MickJav

AWF VIP
Local time
Today, 20:27
Joined
Nov 28, 2005
Messages
1,832
Thanks @MajP Going to use this for my next project which will be a Open Code Code Library, I use Total Visual SourceBook 2013 But never built one before :) , I should also be able to get the code looking like the VB editor,

Love the images that will make it look really cool Thanks

P.S. I will test it on my mrs 64 bit system.

keep safe mick
 

isladogs

CID Moderator
Staff member
Local time
Today, 20:27
Joined
Jan 14, 2017
Messages
13,195
Sorting alphabetically by the looks of it?
Can you get rid of the leading L ?
That wouldn't stop it sorting alphabetically as the 'number parts' like 3.1.2 are not actually numbers
One way is to sort using a derived number column where e.g. L3.11.2 becomes 31102, L3.1.3 becomes 30103, L3.2=>30200 etc

NOTE I haven't tried any of this code & there may be a better way of sorting already built in ???
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom