error 91 please help as i am stuck 
Author Message
 error 91 please help as i am stuck

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



Thu, 11 Nov 2004 13:11:06 GMT  
 error 91 please help as i am stuck
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

Quote:
> sqlnames = sqlnames & "from studentdetails order by "



Quote:
> 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



Thu, 11 Nov 2004 14:05:36 GMT  
 error 91 please help as i am stuck
hi

thanx for that


Quote:
> 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



Thu, 11 Nov 2004 15:34:44 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. HELP : Error 91 : Run-Time Error 91 Object Variable or With

2. Please help with VB4.0 Object Server error and error 91

3. With Block error 91 Please help

4. Object variable or With block variable not set (Error 91) Please Help

5. Help Please - Error 91 - Data Control

6. Object Variable not set , Run Time error 91, please Help

7. Reposition error 91, Please Help

8. Reposition error 91, Please Help

9. I am stuck with DAO need help please

10. Please Help. I am stuck

11. Error 91 - Object Variable Not Set **** Need Help

12. Help needed with SQL (runtime Error 91)

 

 
Powered by phpBB® Forum Software