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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run time error 91

Status
Not open for further replies.

bugzLue

IS-IT--Management
Feb 27, 2001
57
US
I am getting this Runtime error '91'
Object variable or With block variable not set

and this is where the Debug gos to:


Private Sub Select_Data()

Dim itmNew As ListItem

Set rsPlants = New ADODB.Recordset
====> Set rsPlants = objPlants.Select_Hybrid


ListView1.ListItems.Clear


thank for any help Live to learn or die trying
 
Your problem object looks like objPlants.Select_Hybrid. Can you check if you have initialised it and it has a valid value?
 
Where is objPlants declared? It looks as if objPlants might not have been created at this point. What does it do? How does it setup the rsPlants recordset?

Post a bit more information and someone might be able to help :)


Must think of a witty signature
 
This is the code in the class:

Public Function Select_Hybrid(Optional ID As String) As Object

Dim strSQL As String

On Error GoTo BadSelect

strSQL = "SELECT * FROM Plants"

If Trim(&quot; &quot; & ID) <> &quot; &quot; Then
strSQL = strSQL & &quot; Where Id = '&quot; & ID & &quot;'&quot;
End If

Set Select_Hybrid = cnPlants.Execute(strSQL)

Exit Function

BadSelect:

Debug.Print Err.Number & Err.Description
Select_Hybrid = Err
Err.Clear


End Function


++++++++++++++++++++++++
Live to learn or die trying
 
And this is the code for the function:

Private Sub Select_Data()

Dim itmNew As ListItem

Set rsPlants = New ADODB.Recordset
Set rsPlants = objPlants.Select_Hybrid


ListView1.ListItems.Clear


If rsPlants.EOF And rsPlants.BOF Then
Set rsPlants = Nothing
Exit Sub
End If

Do Until rsPlants.EOF
Set itmNew = ListView1.ListItems.Add _
(, rsPlants(&quot;ID&quot;), rsPlants(&quot;ID&quot;))
itmNew.SubItems(2) = rsPlants(&quot;Code&quot;)
itmNew.SubItems(3) = rsPlants(&quot;PollinationDate&quot;)
itmNew.SubItems(4) = rsPlants(&quot;HarvestDate&quot;)
itmNew.SubItems(5) = rsPlants(&quot;FirstBloomDate&quot;)
itmNew.SubItems(6) = rsPlants(&quot;Species&quot;)
itmNew.SubItems(7) = rsPlants(&quot;Genera&quot;)
itmNew.SubItems(8) = rsPlants(&quot;Cultiver&quot;)
itmNew.SubItems(9) = rsPlants(&quot;Awards&quot;)
itmNew.SubItems(10) = rsPlants(&quot;Comments&quot;)
itmNew.SubItems(11) = rsPlants(&quot;Pod_ID&quot;)
itmNew.SubItems(12) = rsPlants(&quot;Pollen_ID&quot;)
itmNew.SubItems(13) = rsPlants(&quot;Photo&quot;)

rsPlants.MoveNext

Loop

Set rsPlants = Nothing



End Sub Live to learn or die trying
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top