ActiveX TreeView on an Access Form

D

DanRoss

I'm tring to use a TreeView control from the windows common controls v6.0 on
an access form.

I drop the control on the form - no problem. The problme is referencing the
object.


Dim oTreeView As MSComctlLib.TreeView
Set oTreeView = Me.TreeView0 << -------------- Type Miss Match no matter
how i reference it or declare it above.

Am I missing something fundamental to using ActiveX controls on an Access
2007 form?

TIA.

Dan
 
R

Rob Parker

Hi Dan,

With the declaration you've got, you can set the reference like this:
Set oTreeView = Me.TreeView0.Object
and then use statements such as
oTreeView.Nodes.Clear


Alternatively, and simpler, is to omit the declaration and Set statement
completely. For example, here's some code out of a real-life application of
mine:
Dim nod As Object
... 'other declarations included, but not shown here
With Me![tvwWP] 'tvwWP is the name of the treeview control on the form
'Clear previous values
.Nodes.Clear
'Fill Level 1
Set rst = dbs.OpenRecordset(strQuery1, dbOpenForwardOnly)
Do Until rst.EOF
strNode1Text = StrConv("Level1" & rst![PhaseName], vbLowerCase)
Set nod = .Nodes.Add(Key:=strNode1Text, Text:=rst![PhaseName])
'Save the PhaseID to retrieve for use in form
nod.Tag = rst![PhaseID]
nod.Expanded = rst!Expanded
rst.MoveNext
Loop
rst.Close
...
End With

HTH,

Rob
 
D

DanRoss

Thanks Rob - that did it . . .

Rob Parker said:
Hi Dan,

With the declaration you've got, you can set the reference like this:
Set oTreeView = Me.TreeView0.Object
and then use statements such as
oTreeView.Nodes.Clear


Alternatively, and simpler, is to omit the declaration and Set statement
completely. For example, here's some code out of a real-life application
of mine:
Dim nod As Object
... 'other declarations included, but not shown here
With Me![tvwWP] 'tvwWP is the name of the treeview control on the
form
'Clear previous values
.Nodes.Clear
'Fill Level 1
Set rst = dbs.OpenRecordset(strQuery1, dbOpenForwardOnly)
Do Until rst.EOF
strNode1Text = StrConv("Level1" & rst![PhaseName], vbLowerCase)
Set nod = .Nodes.Add(Key:=strNode1Text, Text:=rst![PhaseName])
'Save the PhaseID to retrieve for use in form
nod.Tag = rst![PhaseID]
nod.Expanded = rst!Expanded
rst.MoveNext
Loop
rst.Close
...
End With

HTH,

Rob

DanRoss said:
I'm tring to use a TreeView control from the windows common controls v6.0
on an access form.

I drop the control on the form - no problem. The problme is referencing
the object.


Dim oTreeView As MSComctlLib.TreeView
Set oTreeView = Me.TreeView0 << -------------- Type Miss Match no matter
how i reference it or declare it above.

Am I missing something fundamental to using ActiveX controls on an Access
2007 form?

TIA.

Dan
 

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