"Object doesn't support this property or method" Error on Tree Con

L

Lee Vance

I have an Access 2003 application that was built in an earlier version of
Access. Originally, I was getting an error "There is no object in this
control".

I have replaced the old image control (COMCTL.ImageListCtrl.1) with a newer
one (MSComctlLib.ImageListCtrl.2).

I am now getting "Object doesn't support this property or method". Here is
the form load code:


Private Sub Form_Load()
Dim db As Database
Dim rs1 As Recordset
Dim rs2 As Recordset
Dim ctlTree As Control
Dim ctlImages As Control
Dim nodObject As Node

Set db = CurrentDb
Set ctlImages = Me.ctlImageList

' fill the provenience selector with the site numbers and placeholders for
children
' SI=site, BL=block, BP=block part, UN=unit, UP=unit part, LV=level
Set ctlTree = Me.Controls("tvwProvenience")


ctlTree.ImageList = ctlImages.Object
Set rs1 = db.OpenRecordset("SELECT fldResourceID, fldResourceTempNumber, " _
& "fldResourceNumber from tblResources where fldProjectIDref = " &
Forms("frmProjectSelect").txtProjectIDref _
& " ORDER BY fldResourceNumber, fldResourceTempNumber")
With ctlTree.Nodes
Do Until rs1.EOF
Set nodObject = .Add(, , "SI" & rs1!fldResourceID, _
IIf(Len(rs1!fldResourceNumber) > 0, rs1!fldResourceNumber,
rs1!fldResourceTempNumber), 1)
Set nodObject = .Add(nodObject.key, tvwChild, nodObject.key & "BL",
"hold")
rs1.MoveNext
Loop
End With

' then fill the materials control
' GN=general category, DT=detail category, CI=code item, CO=code
Set ctlTree = Me.Controls("tvwMaterials")
ctlTree.ImageList = ctlImages.Object
Set rs1 = db.OpenRecordset("SELECT fldArtifactDescriptionGeneralCode,
fldArtifactDescriptionGeneral " _
& "from tblArtifactDescGeneral ORDER BY
fldArtifactDescriptionGeneralCode")
Set rs2 = db.OpenRecordset("SELECT fldArtifactDescriptionDetailCode,
fldArtifactDescriptionGeneralCodeRef, " _
& "fldArtifactDescriptionDetail, fldDetailReference from
tblArtifactDescDetail ORDER BY " _
& "fldArtifactDescriptionGeneralCodeRef,
fldArtifactDescriptionDetailCode")

With ctlTree.Nodes
Do Until rs1.EOF
' add code for referencing tblArtifactDescGeneral
Set nodObject = .Add(, , "GN" & rs1!fldArtifactDescriptionGeneralCode, _
rs1!fldArtifactDescriptionGeneral, 3)
Do Until rs2.EOF
' add the child controls under the parents
If rs2!fldArtifactDescriptionGeneralCodeRef = Mid(nodObject.key,
InStr(nodObject.key, "GN") + 2) Then
Set nodObject = .Add(nodObject.key, tvwChild, nodObject.key & "DT"
& rs2!fldArtifactDescriptionDetailCode _
& "[" & Nz(rs2!fldDetailReference, "") & "]",
rs2!fldArtifactDescriptionDetail, 3)
Set nodObject = .Add(nodObject.key, tvwChild, Left(nodObject.key,
InStr(nodObject.key, "[") - 1) & "CI", "hold")
Set nodObject = nodObject.Parent.Parent
End If
rs2.MoveNext
Loop
rs2.MoveFirst
rs1.MoveNext
Loop
End With

Set nodObject = Nothing
Set ctlImages = Nothing
Set ctlTree = Nothing
rs1.Close
Set rs1 = Nothing
rs2.Close
Set rs2 = Nothing
db.Close
Set db = Nothing
cmdBuildCount_Click
cmdBuildList_Click
End Sub


Is there a different control I should use for the image list or for the
tree, or does my code need to be updated?

I appreciate any help I can get on this. Thanks

Lee
 

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

Similar Threads

Run time error in VBA Code 1
Data Type Conversion error 5
Split not working correctly 2
query on query 1
On Change Update Subform 1
Recordset Code Help 12
trouble printing variavel 1
How to do this? 2

Top