run-time error '-214735251 (80020005) type mismatch on a listbox

dasrocko1

New Member
Joined
Jul 7, 2016
Messages
2
I am pulling my data for my listbox from SQL Oracle. SELECT * FROM TABLE WHERE THIS= THAT is giving me a recordset count over 8700. for testing I queried only 25 records and my listbox worked but when I do the whole recordset I get 'run-time error '-214735251 (80020005)': Could not set the List property. Type mismatch'.

Private Sub UserForm_Initialize()
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strSQL As String
Dim i As Integer
i = 0
Me.lb1.Clear
Me.lb1.ColumnWidths = "70;65;250;125;60;50;50;15"
Set cn = New ADODB.Connection
cn.Open ("PROVIDER=ORAOLEDB.ORACLE;DATA SOURCE=ICVP;USER ID=*****;PASSWORD=*****")
Set rs = New ADODB.Recordset
strSQL = "SELECT * FROM TABLE WHERE THIS= THAT"
rs.Open strSQL, cn, adOpenKeyset, adLockBatchOptimistic
rs.MoveFirst
Do Until rs.EOF
With Me.lb1
.AddItem
.List(i, 0) = rs("A")
.List(i, 1) = rs("B")
.List(i, 2) = rs("C")
.List(i, 3) = rs("D")
.List(i, 4) = rs("E")
.List(i, 5) = rs("F")
.List(i, 6) = rs("G")
.List(i, 7) = rs("H")
i = i + 1
End With
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
End Sub

I tried to do .List(i, 0) = Val(rs("A")) around all the fields but got 'Run-time error'94': Invalid use of Null'

Any Idea's

Thanks
Rich A
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Are there Null values in some of the fields?
 
Upvote 0
I did find some so I changed my SQL up using nvl() and changed all null values to zero and still got the same error
 
Upvote 0
What happens if you dump the recordset to a worksheet using CopyFromRecordset and then populate the listbox using either RowSource or List?
 
Upvote 0

Forum statistics

Threads
1,214,902
Messages
6,122,161
Members
449,069
Latest member
msilva74

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top