Solved

listbox not populating all fields

Posted on 2013-10-30
9
236 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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;…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

863 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now