Results 1 to 19 of 19

Thread: [RESOLVED]BIG problem run time error 91

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2004
    Posts
    790

    Resolved [RESOLVED]BIG problem run time error 91

    I am trying populate a listbox within a SStab control with data when the form loads from a SQL table (instead of the stored procedure I have within that I have commented out )and I get the following :

    RUNTIME ERROR 91 OBJECT VARIABLE or block variable not set..

    someone please help


    Private Sub Form_Load()
    'Dim rs As ADODB.Recordset
    Dim sql_stm As String
    Dim SADOconnect As String

    Dim rs As ADODB.Recordset
    Set rs = Adodc1.Recordset
    'MsgBox rs.RecordCount


    SADOconnect = "PROVIDER = SPWHPSQ00;" & _
    "Data Source = ilr_test ;" & _
    "Trusted_Connection = yes"

    'sql_stm = "exec sp_ILR_Admin_select_Request_status"
    sql_stm = "select * from Requests"

    rs.Open sql_stm, SADOconnect, adOpenDynamic, adLockPessimistic
    Set rs = Nothing
    MsgBox rs(0)

    End Sub
    Last edited by Christopher_Arm; Feb 10th, 2006 at 09:31 AM.

  2. #2
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: BIG problem run time error 91

    On what line does the error occur?


    Has someone helped you? Then you can Rate their helpful post.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2004
    Posts
    790

    Re: BIG problem run time error 91

    Quote Originally Posted by manavo11
    On what line does the error occur?

    the rs.open sql_stm line.

  4. #4

  5. #5
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: BIG problem run time error 91

    Why this line?

    Set rs = Adodc1.Recordset

    I think it should be :

    Set rs = New ADODB.Recordset

    or just :

    Dim rs As New ADODB.Recordset

    could be wrong...


    Has someone helped you? Then you can Rate their helpful post.

  6. #6
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: BIG problem run time error 91

    Quote Originally Posted by MartinLiss
    Why have you commented out this line?

    'Dim rs As ADODB.Recordset
    It's farther down as well (redeclared).


    Has someone helped you? Then you can Rate their helpful post.

  7. #7
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: BIG problem run time error 91

    VB Code:
    1. Dim rs As ADODB.Recordset
    2. Set rs = New ADODB.Recordset

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2004
    Posts
    790

    Re: BIG problem run time error 91

    Now it READS with the run time error 3706 provider can not be found it may not be properly be installed.

  9. #9
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: BIG problem run time error 91

    What type of database uses the SPWHPSQ00 provider?

  10. #10

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2004
    Posts
    790

    Re: BIG problem run time error 91

    it is a SQL database that houses my stored procedures and tables.

  11. #11
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: BIG problem run time error 91

    The provider name for SQL Server is sqloledb.

    Is SPWHPSQ00 the name of your Server?

    "provider=sqloledb;data source=SPWHPSQ00;initial catalog=ilr_test;trusted_connection=yes"

    or
    "provider=sqloledb;data source=SPWHPSQ00;initial catalog=ilr_test;integrated security=sspi"
    Last edited by brucevde; Feb 9th, 2006 at 03:06 PM.

  12. #12

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2004
    Posts
    790

    Re: BIG problem run time error 91

    Quote Originally Posted by brucevde
    The provider name for SQL Server is sqloledb.

    Is SPWHPSQ00 the name of your Server?

    "provider=sqloledb;data source=SPWHPSQ00;initial catalog=ilr_test;trusted_connection=yes"

    or
    "provider=sqloledb;data source=SPWHPSQ00;initial catalog=ilr_test;integrated security=sspi"

    Great thanks guys, but now how do i display the data in the listbox on the form load within an SSTABcontrol on the form ?

  13. #13
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: BIG problem run time error 91

    Something like this :

    VB Code:
    1. If Rs.RecordCount <> 0 Then
    2.         Rs.MoveFirst
    3.         Do While Not Rs.EOF
    4.             cboCity.AddItem Rs.Fields("Name")
    5.             Rs.MoveNext
    6.         Loop
    7.        
    8.         Rs.Close
    9.         Set Rs = Nothing
    10.     End If


    Has someone helped you? Then you can Rate their helpful post.

  14. #14

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2004
    Posts
    790

    Re: BIG problem run time error 91

    Quote Originally Posted by manavo11
    Something like this :

    VB Code:
    1. If Rs.RecordCount <> 0 Then
    2.         Rs.MoveFirst
    3.         Do While Not Rs.EOF
    4.             cboCity.AddItem Rs.Fields("Name")
    5.             Rs.MoveNext
    6.         Loop
    7.        
    8.         Rs.Close
    9.         Set Rs = Nothing
    10.     End If
    This part I am curious about cbocity.addItem does what exactly and does rs.Fields take the the field name references from the table itself ?
    cboCity.AddItem Rs.Fields("Name")

    And how would this work with a listview ?
    Last edited by Christopher_Arm; Feb 9th, 2006 at 04:03 PM.

  15. #15
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: BIG problem run time error 91

    cboCity is the name of a combobox. Change it with the name of your listbox.

    The Fields gives you access to the columns you have selected from the select statement above.


    Has someone helped you? Then you can Rate their helpful post.

  16. #16

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2004
    Posts
    790

    Re: BIG problem run time error 91

    How do I populate multiple fields in the list box ?

  17. #17
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: BIG problem run time error 91

    Listbox.AddItem Rs.Fields("SomeField") & vbTab & Rs.Fields("AnotherField")

    Or replace vbTab with a space, an underscore or whatever you want.


    Has someone helped you? Then you can Rate their helpful post.

  18. #18

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2004
    Posts
    790

    Re: BIG problem run time error 91

    Quote Originally Posted by manavo11
    Listbox.AddItem Rs.Fields("SomeField") & vbTab & Rs.Fields("AnotherField")

    Or replace vbTab with a space, an underscore or whatever you want.

    Thanks guys you've been a big help.

    PS. I want to do this trick for every listbox that appears within each tab i nthe tab control. There are four of them is there anything else to consder here when doing that ?

  19. #19
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: BIG problem run time error 91

    Nothing different I think, just use <ListboxName>.AddItem <Your Items> with all of them.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width