Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Invalid Object

Status
Not open for further replies.

tjm77

Programmer
Oct 2, 2000
15
US
I am getting an invalid object error when trying to run a ActiveX tree in a form. I am running 2000, but i have the same code in a 97 form and it works fine. Any thoughts on why I am getting that error? code:

Dim rstSchedules As Recordset
Dim db As Database
Dim nodX As Node
Dim lastWorkbook, lastSheet As String
'On Error GoTo loadError
Set db = CurrentDb()

If IsMissing(tworkbook) Then
Set rstSchedules = db.OpenRecordset("SELECT tblSchedule.* FROM tblSchedule WHERE (IsNumeric([F2]) or IsNumeric([F3]) or [F3] = 'SSS' ) ORDER BY tblSchedule.workbook, tblSchedule.sheet, tblSchedule.F2;", dbOpenDynaset)
ActiveXCtl0.Nodes.Clear
Set nodX = ActiveXCtl0.Nodes.Add(, , "R", "Schedules")
ActiveXCtl0.Nodes(1).expanded = True
Else
Set rstSchedules = db.OpenRecordset("SELECT tblSchedule.* FROM tblSchedule WHERE (workbook = '" & tworkbook & "') AND (IsNumeric([F2]) or IsNumeric([F3]) or [F3] = 'SSS') ORDER BY tblSchedule.workbook, tblSchedule.sheet, tblSchedule.F2;", dbOpenDynaset)

End If

Do While Not rstSchedules.EOF
If rstSchedules!workbook <> lastWorkbook Then ' new workbook
Set nodX = ActiveXCtl0.Nodes.Add(&quot;R&quot;, tvwChild, rstSchedules!workbook, rstSchedules!workbook & &quot; &quot; & Format(rstSchedules!dateRead, &quot;mm/dd/yy&quot;))
lastWorkbook = rstSchedules!workbook
End If

If rstSchedules!sheet <> lastSheet Then 'New worksheet
-------This is where I am getting the error:---------------------
Set nodX = ActiveXCtl0.Nodes.Add(rstSchedules!workbook, tvwChild, rstSchedules!sheet, rstSchedules!sheet)
lastSheet = rstSchedules!sheet
End If

Set nodX = ActiveXCtl0.Nodes.Add(rstSchedules!sheet, tvwChild, &quot;z$&quot; & rstSchedules!id, rstSchedules!F1 & &quot; (&quot; & rstSchedules!F2 & &quot;)&quot;)
ActiveXCtl0.Nodes(ActiveXCtl0.Nodes.count).Checked = rstSchedules!selected
rstSchedules.MoveNext
Loop
 
Access 2000 has ADO as well a DAO data objects. Make sure you have a reference set to a DAO library and explicitly define the data objects and it should be okay.

Dim db As DAO.Database
Dim rstSchedules As DAO.Recordset
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top