TreeView Menu

M

Marco

Hi. How can I create a treeview menu. A menu that if I click in one option
that option will open a for or query.

Regards,
Marco
 
M

Marco

Hi.

It seems to be hard hey?

Any example database where I can check?

Thanks,
Marco
 
P

Pete D.

The site I listed has instructions on creating treeview controls with sample
code.
 
M

Marco

Hello. I'm trying to do something different in Access. I would like to create
a Navision layout menu.


I saw that link Rob. I talked to that company and they don't mind if I
change the code, my question is how to give a action to the results/nodes.

Because, It's easy to change the table data, my problem is how to set an
action to each option.

Regards,
Marco
 
M

Maurice

Well that's where the hard part starts because in code you have to react to
the treeview nodeclick action. Every node gets an id and based on the
nodeclick you have to check the id so you can see what node was clicked and
what you want to do next. In my opinion you learn best by downloading a
couple of samples and step through the code to see how it works.
 
P

Pete D.

If you use unique names for tables, forms and such, you can use something
like

Private Sub TreeView1_DblClick()
Dim trv As Control, strFormName As String
Set trv = Forms!frm_TreeMenu!TreeView1
On Error Resume Next
'Get Form Name.
strFormName = Left(trv.Nodes(trv.SelectedItem.Index).Key,
InStr(trv.Nodes(trv.SelectedItem.Index).Key, "1") - 1)
'See below for critical naming convention to select and execute correct
code.
If Left(strFormName, 3) = "rpt" Then
DoCmd.OpenReport strFormName, acPreview

Now this is not ideal and I didn't have time to finish it. One of the pro's
could tell you how to figure out what the item is (form, rpt...) and then
pass it to the correct action. In my case I just hard coded it as I didn't
have time or at the time the talent to make it fancy and I was only dealing
with a few forms and reports.
 
Top