Treeview Error

C

Craig

I'm using Access 2003. I have a treeview control (6) on a form and I am
trying to populate the nodes via code. On load, I get the following message:

Error: 35613 Imagelist must be initialized before it can be used.

How do I resolve this?

Thanks.
 
D

David C. Holley

Been there done that - easy mistake. When you're using a TreeView that
is set to display images, you have to add a ImageList control to the
form, name it and set the TreeView to reference it. The ImageList is a
holder for the images.

Assuming that you want to use images...

1. Add the ImageList to the form by inserting it. (Tools>Insert>ActiveX
Controls

2. Load up the ImageList with any images that you're going to be using.
I used IconSearcher to snoop my PC to collect icons. (Google
IconSearcher and you'll find it on the internet for a minor price)

3. Right click on the TreeView and display the properties for the
TreeView under the TreeView CTRL Object selection (not the regular
PROPERTIES option)

4. You'll see a dropdown box from which you can select the name of the
ImageList.

If you don't want to use images, change the properties of the TreeView
to NOT display images. That should fix it without having to follow steps
1 - 3.

David H
 
C

Craig

Thanks...that worked well.
--
Craig


David C. Holley said:
Been there done that - easy mistake. When you're using a TreeView that
is set to display images, you have to add a ImageList control to the
form, name it and set the TreeView to reference it. The ImageList is a
holder for the images.

Assuming that you want to use images...

1. Add the ImageList to the form by inserting it. (Tools>Insert>ActiveX
Controls

2. Load up the ImageList with any images that you're going to be using.
I used IconSearcher to snoop my PC to collect icons. (Google
IconSearcher and you'll find it on the internet for a minor price)

3. Right click on the TreeView and display the properties for the
TreeView under the TreeView CTRL Object selection (not the regular
PROPERTIES option)

4. You'll see a dropdown box from which you can select the name of the
ImageList.

If you don't want to use images, change the properties of the TreeView
to NOT display images. That should fix it without having to follow steps
1 - 3.

David H
 
D

David C. Holley

let me know when you're ready to do drag and drop. There doesn't appear
to be any good examples out there. It was like pulling teeth.
 
C

Craig

Actually, I would be very interested in incorporating that into my
application. What examples do you have?

Thanks for your help with this...
 
D

David C. Holley

Craig,

How close are you to starting to implement Drag & Drop for your
TreeView? I wittled down mine with the intent of added detailed
comments, but have not yet gotten to that point.

Alex,
Once I've gotten the comments added, I was going to send the file to you
to review to see if there was anything unclear and/or fill in the
blanks. One of my frustrations with the various examples that I found is
that they all lacked comments explaining in simple terms what they did.
Would you be up for the review.

David H
 
A

Alex Dybenko

hi David,
Alex,
Once I've gotten the comments added, I was going to send the file to you
to review to see if there was anything unclear and/or fill in the
blanks. One of my frustrations with the various examples that I found is
that they all lacked comments explaining in simple terms what they did.
Would you be up for the review.

yes, pls do so when you get ready
 
D

David C. Holley

One of the issues that I ran into was the need to uniquely identify each
node when the TV is loaded with records from more than 1 table where the
primary key for each record is an Autonumber field. Since both table
have an Autonumber, its entirely possible that the same value can exist
in both tables. This isn't a problem until you try to use the values as
the key for the TV since the value would repeat in the TV if left
unaltered. To resolve that problem, I implemented a schema for the node
keys that guarantees uniqueness. Basically the key has three components...

[prefixLength][prefix]:[keyValue]
06ACT:printInvoice
10INVOICE:85720
09CLIENT:4
09MASTER:4

In my case since I was listing records from both the CLIENTS and MASTER
ACCOUNTS table, the key value of 4 is repeated and thus causes an issue
when using it for a node's key. Using the schema above, I was able to
use the table key for the node key without any further issues.

The first two characters are used to identify the length of the prefix,
including the length and up to and including the colon [:], so that the
key can be extracted if needed to update the related record if needed
using this function...

Function getTreeViewKeyValue(ByRef strString)

getTreeViewKeyValue = Mid(strString, CInt(Left(strString, 2) + 1),
Len(strString) - CInt(Left(strString, 2)))

End Function
 
D

David C. Holley

Yes that will work - as long as you're loading the TreeView from a
*SINGLE* table. When you're loading it from *MULTIPLE* tables, then it
won't, because the *value* contained in the PubId field will more likely
be repeated if you're using an AutoNumber field in your tables for the
primary keys.
 
D

Damir Matijevic

Hi David,

David C. Holley said:
Yes that will work - as long as you're loading the TreeView from a
*SINGLE* table. When you're loading it from *MULTIPLE* tables, then it
won't, because the *value* contained in the PubId field will more likely
be repeated if you're using an AutoNumber field in your tables for the
primary keys.

OK, but, you can change code like this:


mNode.Key = CInt(rsPublishers!PubID) & "table1"


mNode.Key = CInt(rsPublishers!PubID) & "table2"

etc...

to indicate multiple tables....

Damir
 
D

David C. Holley

Ok, so we do that. When you need to execute an action on the source
record - say changing its description via LabelEdit or opening a form to
display the detail via NodeClick, there is no way to extract the record
ID from the key since the examples provide do not contain information on
the length of the key or the length of the table name, which brings us
back to my original post and technique.
 
D

Damir Matijevic

Hi David
David C. Holley said:
Ok, so we do that. When you need to execute an action on the source
record - say changing its description via LabelEdit or opening a form to
display the detail via NodeClick, there is no way to extract the record ID
from the key since the examples provide do not contain information on the
length of the key or the length of the table name, which brings us back to
my original post and technique.

If you say so...

I never tried LabelEdit, but NodeClick is not a problem...

However, may I send you few screenshots on you mail?

Damir
 
D

David C. Holley

I don't see why. I've had a TV up and running for 3 months now with Drag
& Drop just implemented.
 
D

Damir Matijevic

Damir Matijevic said:
Hi David,



OK, but, you can change code like this:


mNode.Key = CInt(rsPublishers!PubID) & "table1"


mNode.Key = CInt(rsPublishers!PubID) & "table2"

etc...

to indicate multiple tables....

Damir

I'm sorry, I made mistake:

It should be:

mNode.Key = CInt(rsPublishers!PubID) & " table1"


mNode.Key = CInt(rsPublishers!PubID) & " table2"

note: there is leading space in " table2" as in MSDN example:

mNode.Key = CInt(rsPublishers!PubID) & " ID"


Let say I have two tables - Table 1 and Table 2

For Table1 I will use T01
For Table2 T02
etc.

I will not use actual table name, but always four characters: leading space
+ three characters to represent Table

So now I have:
mNode.Key = CInt(rsPublishers!PubID) & " T01" 'first table
mNode.Key = CInt(rsPublishers!PubID) & " T02" 'second table
etc


Can I now extract rsPublishers!PubID?

Damir
 
D

Damir Matijevic

Damir Matijevic said:
I'm sorry, I made mistake:

It should be:

mNode.Key = CInt(rsPublishers!PubID) & " table1"


mNode.Key = CInt(rsPublishers!PubID) & " table2"

note: there is leading space in " table2" as in MSDN example:

mNode.Key = CInt(rsPublishers!PubID) & " ID"


Let say I have two tables - Table 1 and Table 2

For Table1 I will use T01
For Table2 T02
etc.


or like this

For Table1 I will use TBA
For Table2 TBB
TBC
TBD

etc


mNode.Key = CInt(rsPublishers!PubID) & " TBA"

and then, assuming rsPublishers!PubID is AutoNumber

rsPublishers!PubID=Val(Node.Key)


Damir
 

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