> It is complaining about dbtpet not being set.
> Did you open the database with
> Set dbtpet = opendatabase("xxxxxxxx")
> Once I opened the database I no longer got the error,
> But I did get an "Syntax error in Order By clause" message. You need a
space
> after the Order By
> > sqlnames = sqlnames & "from studentdetails order by "
> > hi all
> > could someone look at this code a see if they can find why i get
> > a run-time error 91
> > object varible or with block varible not set
> > and when i hit debug it highlights the line i have shown by the **
> > Public Sub updatetree()
> > Dim indx As Integer
> > Dim rsallnames As Recordset
> > Dim sqlnames As String
> > Dim currentalpha As String
> > Dim sstudentname As String
> > Tvstudents.Nodes.Clear
> > sqlnames = "select studentID, Firstname, Lastname, Formclass "
> > sqlnames = sqlnames & "from studentdetails order by"
> > sqlnames = sqlnames & "Firstname, Lastname, Formclass "
> > ** Set rsallnames = dbtpet.OpenRecordset(sqlnames) **
> > If (rsallnames.RecordCount > 0) Then
> > rsallnames.MoveFirst
> > End If
> > For indx = Asc("A") To Asc("Z")
> > currentalpha = Chr(indx)
> > Set studentdetailsnode = Tvstudents.Nodes.Add(, , currentalpha,
> > currentalpha)
> > If (Not rsallnames.EOF) Then
> > Do While UCase$(Left(rsallnames!FirstName, 1)) = currentalpha
> > With rsallnames
> > sstudentname = !FirstName & ", "
> > sstudentname = sstudentname & !LastName
> > If (Not IsNull(!FormClass)) Then
> > sstudentname = sstudentname & " " & !FormClass & " "
> > End If
> > End With
> > DoEvents
> > Set studentdetailsnode = Tvstudents.Nodes.Add(currentalpha, _
> > tvwChild, "ID" & CStr(rsallnames!studentID), sstudentname)
> > rsallnames.MoveNext
> > If (rsallnames.EOF) Then
> > Exit Do
> > End If
> > Loop
> > End If
> > Next
> > sbstatus.Panels.Item(1).Text = "There are " & _
> > rsallnames.RecordCount & " Students in the Teacher's Pet Database."
> > rsallnames.Close
> > DoEvents
> > End Sub
> > cheers
> > and thanx