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

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
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,223,268
Messages
6,171,099
Members
452,379
Latest member
IainTru

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