Solved

listbox not populating all fields

Posted on 2013-10-30
9
245 Views
Last Modified: 2013-10-30
vba 2010 excel

I'am populating a listbox via an array:
Arr = objMyRecordset.GetRows
       objMyRecordset.MoveFirst

With UserForm2.ListBox1
.Clear
.Column = Arr
.ColumnCount = 36
'.RowSource = Arr
        .ListIndex = -1
End With


I'AM not getting all the columns to show in the listbox?

so i tried setting the rowsource to "Arr"

But keep getting errors .?


Thanksd
fordraiders
0
Comment
Question by:fordraiders
  • 5
  • 4
9 Comments
 
LVL 33

Expert Comment

by:Norie
ID: 39612058
Try using List and transposing the array.
With UserForm2.ListBox1
    .ColumnCount = objMyRecordset.Fields.Count
    .List = Application.Transpose(Arr)
End With

Open in new window

0
 
LVL 3

Author Comment

by:fordraiders
ID: 39612373
.List = Application.Transpose(Arr)    error on this line <-----------
0
 
LVL 33

Expert Comment

by:Norie
ID: 39612381
Any particular error?

Does your recordset have any null fields?

How many records are in it?
0
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
LVL 3

Author Comment

by:fordraiders
ID: 39612454
error 13 typemismatch..
Does your recordset have any null fields?

"yes"

it varys...after each executing  request
0
 
LVL 3

Author Comment

by:fordraiders
ID: 39612470
I'am using a temp variable to see if the arr is getting this value .
Dim strb As String

strb = objMyRecordset.Fields(15)
strb = strb

and it clearly is...
but once the array is populated it does not show in the listbox ?
0
 
LVL 33

Accepted Solution

by:
Norie earned 500 total points
ID: 39612484
I think the problem might be the nulls.

Try rewriting your query so that they are replaced with blanks, or whatever is appropriate.
0
 
LVL 3

Author Comment

by:fordraiders
ID: 39612493
weird because i have other places in the data where the fields are null?
0
 
LVL 33

Expert Comment

by:Norie
ID: 39612550
Do you mean other places where you are populating listboxes with arrays that have null values?
0
 
LVL 3

Author Closing Comment

by:fordraiders
ID: 39612680
Thanks, got me on the right track !
0

Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question