|
-
Feb 9th, 2006, 02:25 PM
#1
Thread Starter
Fanatic Member
[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.
-
Feb 9th, 2006, 02:29 PM
#2
-
Feb 9th, 2006, 02:31 PM
#3
Thread Starter
Fanatic Member
Re: BIG problem run time error 91
 Originally Posted by manavo11
On what line does the error occur?
the rs.open sql_stm line.
-
Feb 9th, 2006, 02:36 PM
#4
Re: BIG problem run time error 91
Why have you commented out this line?
'Dim rs As ADODB.Recordset
-
Feb 9th, 2006, 02:39 PM
#5
-
Feb 9th, 2006, 02:40 PM
#6
-
Feb 9th, 2006, 02:40 PM
#7
Re: BIG problem run time error 91
VB Code:
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
-
Feb 9th, 2006, 02:46 PM
#8
Thread Starter
Fanatic Member
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.
-
Feb 9th, 2006, 02:47 PM
#9
Re: BIG problem run time error 91
What type of database uses the SPWHPSQ00 provider?
-
Feb 9th, 2006, 02:50 PM
#10
Thread Starter
Fanatic Member
Re: BIG problem run time error 91
it is a SQL database that houses my stored procedures and tables.
-
Feb 9th, 2006, 03:03 PM
#11
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.
-
Feb 9th, 2006, 03:12 PM
#12
Thread Starter
Fanatic Member
Re: BIG problem run time error 91
 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 ?
-
Feb 9th, 2006, 03:53 PM
#13
Re: BIG problem run time error 91
Something like this :
VB Code:
If Rs.RecordCount <> 0 Then
Rs.MoveFirst
Do While Not Rs.EOF
cboCity.AddItem Rs.Fields("Name")
Rs.MoveNext
Loop
Rs.Close
Set Rs = Nothing
End If
Has someone helped you? Then you can Rate their helpful post. 
-
Feb 9th, 2006, 03:58 PM
#14
Thread Starter
Fanatic Member
Re: BIG problem run time error 91
 Originally Posted by manavo11
Something like this :
VB Code:
If Rs.RecordCount <> 0 Then
Rs.MoveFirst
Do While Not Rs.EOF
cboCity.AddItem Rs.Fields("Name")
Rs.MoveNext
Loop
Rs.Close
Set Rs = Nothing
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.
-
Feb 9th, 2006, 04:05 PM
#15
-
Feb 9th, 2006, 04:36 PM
#16
Thread Starter
Fanatic Member
Re: BIG problem run time error 91
How do I populate multiple fields in the list box ?
-
Feb 9th, 2006, 04:38 PM
#17
-
Feb 9th, 2006, 11:03 PM
#18
Thread Starter
Fanatic Member
Re: BIG problem run time error 91
 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 ?
-
Feb 9th, 2006, 11:11 PM
#19
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|