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.