Treeview-Please help a VBA noob

Calvin Koh

New member
Local time
Today, 10:30
Joined
Nov 10, 2007
Messages
2
Dear all,

Would be grateful if any VBA experts can give some hints or tips on a Treeview. I have created a treeview (after a lot of searching and reading, using the most simple code which I do not understand) from a table. The actual table contains about 1000 lines of cardiac diagnosis.
How do I:
1) click on a node on treeview so that it will fill a field in the form with focus-it is something to do with GotFocus?

2) would like to have a search, collapse and expand function if possible (copying from other example can't seem to work).

Please help me. :confused:Appreciate any help or guidance.
Attached an example here.

Thank you
 

Attachments

Took a quick glance and my first impression is that your diag table is liable to give u problems. I see for example, fields diagnosis 1 to 5. What happens if a patient has 6 diagnoses? or 7 or 8? will u simply add these fields as needed? And how about a patient that only has 1 diagnosis? This means d2 to d4 will be empty? making your table look like swiss cheese? relational database design is exactly about avoiding those kind of logical pitfalls. I think the best u can do for now is to catch up on DB design. There are lot's of free tuts on the subject around the Net and Access itself has an excellent sample db for starters.

HTH
Premy
 
How do I:
1) click on a node on treeview so that it will fill a field in the form with focus-it is something to do with GotFocus?
You reference the node with:
node.text

So if you put the following in your NodeClick event, then when you click a node it will copy the text to the txtDx_APPC_1 textbox:

me.txtDx_APCC_1=node.text

2) would like to have a search, collapse and expand function if possible (copying from other example can't seem to work).
You don't seem to have any code yet for these functions. Perhaps you could supply what you have. As Premy says there's loads of examples about. Here's one for searching.

As Premy says, you need to think hard about your table structure because trying to maintain it way way you currently have it would be a nightmare. Take a look here for an example of using hierarchical data from different tables.

hth
Chris
 
Dear Premy and Chris,

Thanks for your comments.

Premy, thank you for the idea. I supposed I should do a one-to-many relationship. Will look into it.

Chris, very informative link and your code works well. Actually I would like the code to be automatically fill in the code field as well. Any idea of doing this?

Thanks again.:)
 

Users who are viewing this thread

Back
Top Bottom